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

huangapple go评论85阅读模式
英文:

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

问题

以下是翻译好的内容:

我没有使用任何接收器或类似的东西。但我在我的Android项目中使用了Firebase。之前我没有遇到过这个异常,但突然间它就出现了!

异常:

W:解绑时抛出异常
    java.lang.IllegalArgumentException: 未注册的服务: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(app):

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(module)

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 位置服务
    implementation 'com.google.android.gms:play-services-location:17.1.0'

    //闪光布局
    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. 在StackOverflow上搜索过,但没有找到适当的解决方案
  3. 检查了Manifest文件
  4. 在测试过程中,Firebase服务运行正常
  5. 不明白在哪里调试什么!

谢谢!

英文:

I haven't used any receiver or something. But I used Firebase in my Android project. Previously I was not getting this exception, but suddenly it is showing!

Exception:

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)

There is nothing important in Manifest file.

Buld.gradle (app):

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 (module)

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);
    }

}

Troubleshooting:

  1. Found this: https://developers.google.com/android/reference/com/google/android/gms/measurement/package-summary
  2. Searched on stackoverflow, but not found proper solution
  3. Checked Manifest file
  4. While testing, Firebase services are running fine
  5. Not understood, what to debug where!

Thank you!

答案1

得分: 35

将以下内容添加到您的 build.gradle 依赖项中:

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

Add this to your build.gradle dependencies:

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

答案2

得分: 13

**此答案的最后更新日期:**2021年2月12日

我们无需采取任何行动。只需等待Google在2021年2月左右发布此“修复”问题。

正如你们中的许多人指出的那样,事实证明存在一些设备配置,即使在我上面提供的解决方法下,仍会触发警告。

不幸的是,我们在SDK方面无法做更多的事情来“消除”这个警告。警告是由“Google Play服务”本身引起的。好消息是问题的根本原因现在已经得到解决,但是它将在2月左右逐渐推出到设备上,所以我们将不得不在未来几个月里忍受这个警告。

我理解这给开发者带来了不便,但是值得注意的是,这只是一个警告,而不是崩溃。因此,请在更新推出之前与我们同舟共济。谢谢!

附言:你们中的许多人评论说,这个警告有时会紧随其后地导致崩溃(带有自己的异常),我非常有信心,在大多数情况下,崩溃与这个警告没有任何关系,只是恰好在警告之后发生。因此,请独立调查崩溃情况,不要理会这个警告。但是,如果你认为崩溃与警告有关,请提供:

崩溃事件时的完整堆栈跟踪
应用程序的相关依赖关系
最好能重现步骤
再次提醒:这个警告是无害的,可以忽略。修复程序将在2021年2月左右推出,开发者无需采取任何行动,修复将适用于Google Play服务本身,现有应用程序将不再生成此警告。

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

英文:

This answer is last updated on: 12-Feb-2021

No action is required from our side. Just wait when Google will release this "Fixed" issue in February 2021 approximately.

> 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.

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

答案3

得分: 1

最近我遇到了类似的问题,但是是在安卓模拟器中使用 AdMob 的时候。我尝试寻找解决方案,但是没有找到任何结果。最终,我关闭了模拟器,打开了 AVD 管理器,清除了模拟器的数据,然后重新打开了模拟器,这样警告异常就消失了。

英文:

I recently had a similar issue but with AdMob in the android emulator. Search for a solution but I found nothing.
finally, I close the emulator, open the AVD manager wipe emulator data, reopen the emulator then the warning exception was gone.

答案4

得分: 0

Dev's who are facing issue on this problem i have checked a lot with com.google.firebase:firebase-bom:26.1.1 i think so some dependencies has to be changed on flutter side so as to support the latest one.

But still you can have your app working without any exception using this :
in your <project>/<app>/build.gradle file ...

Just replace the bom version or you can have my own which i am using too..

dependencies {
    implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
    implementation platform(&#39;com.google.firebase:firebase-bom:25.12.0&#39;)
    implementation &#39;com.google.firebase:firebase-analytics-ktx&#39;
    implementation &#39;com.google.firebase:firebase-messaging&#39;
}
英文:

Dev's who are facing issue on this problem i have checked a lot with com.google.firebase:firebase-bom:26.1.1 i think so some dependencies has to be changed on flutter side so as to support the latest one.

But still you can have your app working without any exception using this :
in your <project>/<app>/build.gradle file ...

Just replace the bom version or you can have my own which i am using too..

dependencies {
    implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
    implementation platform(&#39;com.google.firebase:firebase-bom:25.12.0&#39;)
    implementation &#39;com.google.firebase:firebase-analytics-ktx&#39;
    implementation &#39;com.google.firebase:firebase-messaging&#39;
}

答案5

得分: 0

我也遇到了相同的问题。但在 Firebase 控制台检查后,我发现 Firebase 报错信息为:“存储已满”,这意味着本月的免费数据库空间已用完。

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

英文:

I was facing same issue. But on checking at firebase console I found firebase error as
"Storage full" it means free space for month is used for database.

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

huangapple
  • 本文由 发表于 2020年10月8日 00:03:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/64247956.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定