如何修复 Flutter 中的“解除绑定时抛出异常,java.lang.IllegalArgumentException:服务未注册:lp@9f7d4ca”异常? [复制]

Posted

技术标签:

【中文标题】如何修复 Flutter 中的“解除绑定时抛出异常,java.lang.IllegalArgumentException:服务未注册:lp@9f7d4ca”异常? [复制]【英文标题】:How to fix "Exception thrown while unbinding, java.lang.IllegalArgumentException: Service not registered: lp@9f7d4ca" exception in Flutter? [duplicate] 【发布时间】:2021-02-25 10:46:03 【问题描述】:

我的调试控制台告诉我这个:

W/ConnectionTracker(17934): Exception thrown while unbinding
W/ConnectionTracker(17934): java.lang.IllegalArgumentException: Service not registered: lp@9f7d4ca
W/ConnectionTracker(17934):     at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1557)
W/ConnectionTracker(17934):     at android.app.ContextImpl.unbindService(ContextImpl.java:1692)
W/ConnectionTracker(17934):     at android.content.ContextWrapper.unbindService(ContextWrapper.java:717)
W/ConnectionTracker(17934):     at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):1)
W/ConnectionTracker(17934):     at ci.d(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):2)
W/ConnectionTracker(17934):     at lq.D(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):10)
W/ConnectionTracker(17934):     at lc.a(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):2)

我不知道该怎么做。

【问题讨论】:

我也有同样的情况,正在寻找答案:( 是的,这里也一样。必须是firebase-admob插件,你们用吗? @galloper 我没有,我有 firestore、firebase core、analytics 和 firebase 消息传递 @GuilhermeZamberlamPomini 很有趣,我在横幅更新中看到此错误 - 每次更新后大约 3-5 秒。它必须与 play services 或 firebase 相关 GitHub上有一个与这篇文章相关的已关闭问题:github.com/Baseflow/flutter-geolocator/issues/503 【参考方案1】:

The fix for this warning will be rolled out in February!

编辑 2 月 11 日:从快速测试中,我看到这个警告在 Firebase 消息传递的 v. 8.0.0 中消失了,但包仍在开发中; link to it.

编辑 1 月 13 日:Android Studios 在输出中有一个简洁的选项来折叠行。如果您想摆脱在开发过程中容易干扰的长消息,请右键单击该行并将其折叠。但是因为某些值会发生变化,所以之前要对其进行调整。

从这个堆栈中:

W/ConnectionTracker(13852): java.lang.IllegalArgumentException: Service not registered: ls@ed97760
W/ConnectionTracker(13852):     at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1562)
W/ConnectionTracker(13852):     at android.app.ContextImpl.unbindService(ContextImpl.java:1692)
W/ConnectionTracker(13852):     at android.content.ContextWrapper.unbindService(ContextWrapper.java:717)
W/ConnectionTracker(13852):     at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204714068@20.47.14 (100700-0):1)
...

将折叠的更改为:

java.lang.IllegalArgumentException: Service not registered: 
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:
at android.app.ContextImpl.unbindService(ContextImpl.java:
at android.content.ContextWrapper.unbindService(ContextWrapper.java:
f(:com.google.android.gms.dynamite_measurementdynamite@
...

等等。我建议您保留原始折叠消息并添加一个新消息以记录您正在更改的内容。

我保留了堆栈中的第一条消息,以确保它没有被我忽略。这就是两个警告最终看起来而不是 26 行杂乱代码的方式。

12 月 16 日编辑:The fix for this warning will be rolled out in February。不确定该线程如何/为何被标记为已关闭和已修复,因为有多种变通办法或多或少地起作用。

真正的解决办法是尝试一些建议,如果失败,请等待。

编辑 12 月 13 日:通过此 Git discussion,我们确认此错误不会导致任何其他问题,也不会导致崩溃。

没有抛出错误的旧机器在更新后开始这样做。

我们只需要等待更新将使这些警告消失。

12 月 8 日编辑:Java 和将 SHA 添加到我的 Firebase 控制台都没有帮助!

12 月 4 日编辑:看起来在有问题的机器上,我没有安装 Java。经过多次构建和擦除后,一切看起来都很好。我会注意的!

访问Oracle's site下载!感谢 Talha 对 SHA 的评论(keytool 需要 Java)!

编辑 12 月 3 日:我进行了另一个 Firebase 设置,正如 Timo Bähr 指出的那样,docs for Firebase setup 已更新。如您所见,添加了 firebase-bom,还添加了选择 Java 或 Kotlin 的选项。

仔细检查了我的项目并:

    将所有依赖项更改为 Kotlin(-ktx 结尾) 擦除所有设备数据 删除了旧的未使用的模拟器 冷启动设备(均来自 Android Studio 虚拟设备管理器)

现在错误消失了(现在?)!

// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.1.0')

// When using the BoM, you don't specify versions in Firebase library dependencies

// Declare the dependency for the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics-ktx'

// Declare the dependencies for any other desired Firebase products
// For example, declare the dependencies for Firebase Authentication and Cloud Firestore
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'

11 月 26 日编辑:即使使用 King 之前的修复,异常也会回来。

编辑 11 月 23 日:错误在 1-2 天后再次出现。请查看 King Alawaka 的答案,该答案可能与this Github reply 相同。积极的反馈来自它。 :)

初始响应:更新 Firebase 依赖项后,我摆脱了这些错误。以下是我目前使用的版本:

firebase_core: ^0.5.2
firebase_database: ^4.3.0
firebase_analytics: ^6.2.0
firebase_messaging: ^7.0.3
firebase_crashlytics: ^0.2.3

这可能没有帮助,因为我看到 this git issue 报告的版本与我使用的版本相似。

其他失败的选项:

implementation 'com.google.android.gms:play-services-basement:17.5.0'android\app\build.gradle 仅将某些软件包降级到大约 1 个月大的版本 禁用分析和崩溃分析(也删除了软件包) 切换仿真设备 鞭打这些设备上的所有数据

【讨论】:

运气好吗?你能解决吗?我今天开始遇到这个错误。 请再次检查,因为我进行了另一个似乎正在工作的更新! 感谢您的更新 — @Underscore。不幸的是,仍然收到错误:( PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)) 我收到此错误。 @TalhaChafekar 一定要使用guild.grade 中所需的包,因为我粘贴的包来自文档。删除不需要的并添加您实际需要/使用的。【参考方案2】:

将以下内容添加到您的 android\app\build.gradle

implementation 'com.google.android.gms:play-services-base:17.5.0'
implementation 'com.google.firebase:firebase-analytics:18.0.0'

【讨论】:

最佳答案。我的 build.gradle 不包含 play-services-basement,但包含 firebase 消息传递。所以我也更新了这个: implementation 'com.google.firebase:firebase-messaging:21.0.0' 谢谢。这解决了问题 不适合我 :( 我发现如果我不使用超过 17.4 的任何东西,那么错误不会出现。 我在实施奖励广告时开始遇到此错误,我什至不使用 Firebase。【参考方案3】:

最新Firebase documentation说:

// Add this line
apply plugin: 'com.google.gms.google-services'

dependencies 
    ...
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:26.4.0')

    // Add the dependency for the Firebase SDK for Google Analytics
    // When using the BoM, don't specify versions in Firebase dependencies
    implementation 'com.google.firebase:firebase-analytics-ktx'

    // Add the dependencies for any other desired Firebase products
    // https://firebase.google.com/docs/android/setup#available-libraries

添加firebase-analytics-ktx后错误消失。

【讨论】:

我看到文档发生了变化并添加了 FB bom 以及为 kotlin 的 java 选择 FB 分析的选项。本来希望能有这样的评论回来的,但是改了对应的依赖后错误依旧存在。 我遇到了同样的问题,有什么消息吗? @underscore @almog-koren 请与firebase-bom:26.4.0 再次核对。在我的情况下,错误消失了。刚刚又检查了一遍。

以上是关于如何修复 Flutter 中的“解除绑定时抛出异常,java.lang.IllegalArgumentException:服务未注册:lp@9f7d4ca”异常? [复制]的主要内容,如果未能解决你的问题,请参考以下文章

(Flutter/Dart) 如何修复使用 [ ] 显示列表中的数字

如何修复错误:从android studio运行时flutter中的processDebugMainManifest DEBUG

如何修复 Flutter 中的“参数类型 'Future<int>' 无法分配给参数类型 'int'”

如何修复 Flutter 中的“正在检查 Dart SDK 版本... << 此时出乎意料”错误?

如何修复 Flutter 中的“Checking Dart SDK version... << was unexpected at this time”错误?

如何修复 Flutter 构建问题期间调用的 setState