Android AdMob - NoSuchMethodError: No static method zzand()



当尝试使用Firebase Admob广告时,我遇到了崩溃。我遵循了指南,但我仍然得到这个奇怪的错误:

java.lang.NoSuchMethodError: No static method zzand()Lcom/google/android/gms/common/zzc; in class Lcom/google/android/gms/common/zzc; or its super classes (declaration of 'com.google.android.gms.common.zzc' appears in /data/data/tech.timmo.terminalwatch/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.4.0_0d08c875bcfdb7f644dc6c5ac5fbcb017cb05b7c-classes.dex)
                                                                      at com.google.android.gms.ads.internal.util.client.zza.zzar(Unknown Source)
                                                                      at com.google.android.gms.ads.internal.client.zzl.zza(Unknown Source)
                                                                      at com.google.android.gms.ads.internal.client.zzl.zzl(Unknown Source)
                                                                      at com.google.android.gms.ads.internal.client.zzag.zza(Unknown Source)
                                                                      at com.google.android.gms.ads.MobileAds.initialize(Unknown Source)
                                                                      at com.google.android.gms.ads.MobileAds.initialize(Unknown Source)
                                                                      at tech.timmo.terminalwatch.ConfigActivity$override.onCreate(ConfigActivity.java:77)
                                                                      at tech.timmo.terminalwatch.ConfigActivity$override.access$dispatch(ConfigActivity.java)
                                                                      at tech.timmo.terminalwatch.ConfigActivity.onCreate(ConfigActivity.java:0)
                                                                      at android.app.Activity.performCreate(Activity.java:6251)
                                                                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2403)
                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
                                                                      at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4111)
                                                                      at android.app.ActivityThread.-wrap15(ActivityThread.java)
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1369)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                      at android.os.Looper.loop(Looper.java:148)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5461)
                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

以下是我在onCreate()中的初始化,错误指向MobileAds.initialise的第一行:

MobileAds.initialize(getApplicationContext(), getString(R.string.banner_ad_unit_id));
AdView adView = (AdView) findViewById(R.id.adView);
adView.setAdSize(AdSize.SMART_BANNER);
AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice("9A3855EFE9914A3C40BF5A33DABB4701")
        .build();
adView.loadAd(adRequest);
xml:

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:adSize="SMART_BANNER"
    app:adUnitId="@string/banner_ad_unit_id" />

这种类型的错误提示潜在的原因。

运行应用程序的设备可能不支持您正在使用的SDK元素。

但是在大多数情况下,它们只是由于build.gradlegms库的版本升级而引入的随机错误。

build.gradle依赖项中恢复以前版本的gms,错误应该会消失。等到google发布下一个版本,然后使用版本升级更新库依赖项。

您在此之前更新SDK了吗?

有两个build.gradle文件,项目一个在rootbuild.gradle,模块一个在rootappbuild.gradle。打开项目build.gradle文件

查看所有版本号(buildToolsVersion, compile,…),并根据Android Studio在你将鼠标光标悬停在它们上面时给出的提示更新它们。

如果你不解决,去file->settings->'android SDK'->'SDK tools'更新所有的工具

相关内容

  • 没有找到相关文章

最新更新