为什么我会收到 "Service not registered" 异常,即使我没有在 Android - Java/Kotlin 中使用任何服务?

Why does I'm getting "Service not registered" exception, even though I not used any service in Android - Java/Kotlin?

我没有用过任何接收器什么的。但是我在 Android 项目中使用了 Firebase。以前我没有得到这个异常,但突然出现了!

异常:

W: Exception thrown while unbinding
    java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzjp@4701ac1
        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1751)
        at android.app.ContextImpl.unbindService(ContextImpl.java:1776)
        at android.content.ContextWrapper.unbindService(ContextWrapper.java:741)
        at com.google.android.gms.common.stats.ConnectionTracker.zza(com.google.android.gms:play-services-basement@@17.3.0:55)
        at com.google.android.gms.common.stats.ConnectionTracker.unbindService(com.google.android.gms:play-services-basement@@17.3.0:50)
        at com.google.android.gms.measurement.internal.zziv.zzag(com.google.android.gms:play-services-measurement-impl@@17.5.0:245)
        at com.google.android.gms.measurement.internal.zziv.zzal(com.google.android.gms:play-services-measurement-impl@@17.5.0:262)
        at com.google.android.gms.measurement.internal.zziv.zzc(com.google.android.gms:play-services-measurement-impl@@17.5.0:336)
        at com.google.android.gms.measurement.internal.zziu.zza(com.google.android.gms:play-services-measurement-impl@@17.5.0:2)
        at com.google.android.gms.measurement.internal.zzai.run(com.google.android.gms:play-services-measurement-impl@@17.5.0:7)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.google.android.gms.measurement.internal.zzfy.run(com.google.android.gms:play-services-measurement-impl@@17.5.0:21)

Manifest 文件中没有重要内容。

Buld.gradle(应用):

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0-rc03'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Build.gradle(模块)

dependencies {
    ......

//Google Firebase
    implementation 'com.google.firebase:firebase-auth:19.4.0'
    implementation 'com.google.firebase:firebase-database:19.5.0'
    implementation 'com.google.firebase:firebase-messaging:20.3.0'
    implementation 'com.google.firebase:firebase-storage:19.2.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.5.0'
 //Google Location
    implementation 'com.google.android.gms:play-services-location:17.1.0'

    //Shimmer Layout
    implementation 'com.facebook.shimmer:shimmer:0.5.0'

    //Google Auth
    implementation 'com.google.android.gms:play-services-auth:18.1.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:17.4.0'

BaseApplication

public class BaseApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
        FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(true);
    }

    protected void showLog(String msg) {
        Log.d(this.getClass().getSimpleName(), msg);
    }

}

疑难解答:

  1. 找到这个:https://developers.google.com/android/reference/com/google/android/gms/measurement/package-summary
  2. 在 Whosebug 上搜索,但未找到合适的解决方案
  3. 检查清单文件
  4. 测试时,Firebase 服务 运行 正常
  5. 没看懂,调试什么地方!

谢谢!

将此添加到您的 build.gradle 依赖项中:

dependencies {
    implementation 'com.google.android.gms:play-services-basement:17.5.0'
}

在这个问题上面临问题的开发人员我已经用 com.google.firebase:firebase-bom:26.1.1 检查了很多我认为所以必须在 flutter 方面更改一些依赖项以支持最新的一.

但是您仍然可以使用以下方法让您的应用正常运行: 在你的 //build.gradle 文件中 ...

只需替换 bom 版本,或者您可以拥有我自己的版本,我也在使用它..

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:25.12.0')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-messaging'
}

我遇到了同样的问题。但是在 firebase 控制台检查时,我发现 firebase 错误为 “存储空间已满”表示每月免费 space 用于数据库。

此答案最后更新于: 2021 年 2 月 12 日

我们这边不需要采取任何行动。请等待 Google 大约在 2021 年 2 月发布此“已修复”问题。

As many of you have pointed out, it turns out that there exist some device configurations that trigger the warning even with the workaround I provided above.

Unfortunately there is nothing more we can do to "silence" the warning on the SDK side. The warning is caused by "Google Play Services" itself. The good news is that the root cause of the issue is now fixed, however it will roll out to devices around February, so we will have to live with this warning for a few months.

I understand that it is causing inconvenience for developers, but fwiw it's a warning not a crash. So please bear with us till the update gets rolled out. Thanks

PS: Many of you have commented that this warning is sometimes followed by a crash(with its own exception), I am fairly confident that in most cases, the crash is completely unrelated to this warning and just so happens to occur right after it. So please investigate your crashes independently, just ignoring the warning. If however you think that the crash is related, please provide:

full stack traces at the event of crash relevant dependencies of your app ideally steps to reproduce Bumping this reply again, so it's more visible for folks.

Once again: The warning is benign and is safe to ignore. The fix will get rolled out around Feb 2021, no action is required on developers' side, the fix will apply to google play services itself and existing apps will stop generating the warning.

来源:https://github.com/firebase/firebase-android-sdk/issues/1662#issuecomment-756917362

我最近遇到了类似的问题,但在 android 模拟器中使用了 AdMob。寻找解决方案,但我一无所获。 最后,我关闭模拟器,打开 AVD 管理器擦除模拟器数据,重新打开模拟器然后警告异常就消失了。