嘗試使用Firebase AdMob廣告時發生崩潰。我跟着指導,但我仍然得到這個奇怪的錯誤:Android AdMob - NoSuchMethodError:無靜態方法zzand()
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);
The 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" />