AdMob 导致:无法获得提供商 com.google.android.gms.ads.MobileAdsInitProvider:java.lang.ClassNotFoundException
AdMob causing: unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException
我正在尝试实施 adMob,但我的应用未启动并出现以下错误:
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:7369)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access00(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
at android.app.ActivityThread.installProvider(ActivityThread.java:7353)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access00(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk because: Bad encoded_array value: Failure to verify dex file '/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk': Bad encoded_value method type size 7
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:365)
at dalvik.system.DexFile.<init>(DexFile.java:107)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:892)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:991)
at android.app.LoadedApk.getResources(LoadedApk.java:1248)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2614)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2606)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6724)
... 8 more
我搜索了这个问题,所有的解决方案,比如 ,都说您现在需要在清单中提供 adMob 提供的 App ID。我已经对这个进行了三次检查,清单中的 meta-data
标签下提供了正确的应用程序 ID,您可以在此处看到:
我一直在关注这个官方guide,也看了两遍,还是报这个错。
我还在为 Android 横幅使用专用的测试广告单元 ID,所以我认为这不是问题所在。
还有什么可能导致这种情况?
我遇到了类似的错误,这解决了它。
In biuld.gradle (Module)
android {
...
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
我正在尝试实施 adMob,但我的应用未启动并出现以下错误:
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:7369)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access00(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk"],nativeLibraryDirectories=[/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
at android.app.ActivityThread.installProvider(ActivityThread.java:7353)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6909)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6826)
at android.app.ActivityThread.access00(ActivityThread.java:267)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1981)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk because: Bad encoded_array value: Failure to verify dex file '/data/app/com.aaron.derrystudios.wordresolver-mOF2EngPcA5nT8dd27zx5g==/base.apk': Bad encoded_value method type size 7
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:365)
at dalvik.system.DexFile.<init>(DexFile.java:107)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:892)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:991)
at android.app.LoadedApk.getResources(LoadedApk.java:1248)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2614)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2606)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6724)
... 8 more
我搜索了这个问题,所有的解决方案,比如 meta-data
标签下提供了正确的应用程序 ID,您可以在此处看到:
我一直在关注这个官方guide,也看了两遍,还是报这个错。
我还在为 Android 横幅使用专用的测试广告单元 ID,所以我认为这不是问题所在。
还有什么可能导致这种情况?
我遇到了类似的错误,这解决了它。
In biuld.gradle (Module)
android {
...
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}