我将AdMob集成到我的Android应用程序时出现以下错误。
03-23 03:53:48.374 19077-19077/io.sopo D/DynamitePackage: Instantiated singleton DynamitePackage.
03-23 03:53:48.375 19077-19077/io.sopo D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
03-23 03:53:48.417 19077-20268/io.sopo W/DynamiteModule: Failed to load module via V2: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader" on path: DexPathList[[zip file "/data/app/io.sopo-1/base.apk"],nativeLibraryDirectories=[/data/app/io.sopo-1/lib/arm64, /vendor/lib64, /system/lib64]]
03-23 03:53:48.422 19077-20268/io.sopo I/DynamiteModule: Considering local module com.google.android.gms.piccard.dynamite:0 and remote module com.google.android.gms.piccard.dynamite:12
03-23 03:53:48.422 19077-20268/io.sopo I/DynamiteModule: Selected remote version of com.google.android.gms.piccard.dynamite, version >= 12
03-23 03:53:48.431 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/x-lg-flac
03-23 03:53:48.436 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/adpcm
03-23 03:53:48.438 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/g726
03-23 03:53:48.439 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/eac3
03-23 03:53:48.442 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/ac3
03-23 03:53:48.444 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/lg-wma-voice
03-23 03:53:48.446 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/x-lg-ms-wma
03-23 03:53:48.447 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/theora
03-23 03:53:48.450 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/mjpg
03-23 03:53:48.477 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/evrc
03-23 03:53:48.480 19077-20268/io.sopo W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
03-23 03:53:48.503 19077-20268/io.sopo W/AudioCapabilities: Unsupported mime audio/evrc
03-23 03:53:48.511 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/x-ms-wmv
03-23 03:53:48.513 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/x-ms-wmv
03-23 03:53:48.515 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/divx
03-23 03:53:48.516 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/divx4
03-23 03:53:48.526 19077-20268/io.sopo W/VideoCapabilities: Unsupported mime video/mp4v-esdp
03-23 03:53:48.543 19077-20268/io.sopo I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
03-23 03:53:48.549 19077-20268/io.sopo I/AudioManagerEx: AudioManagerEx created
03-23 03:53:48.550 19077-20268/io.sopo D/AudioManager: getMode name:io.sopo
03-23 03:53:48.595 19077-19077/io.sopo I/Ads: Starting ad request.
03-23 03:53:48.622 19077-20272/io.sopo I/WebViewFactory: Loading com.google.android.webview version 51.0.2704.81 (code 270408150)
03-23 03:53:48.730 19077-20272/io.sopo I/cr_LibraryLoader: Time to load native libraries: 2 ms (timestamps 5476-5478)
03-23 03:53:48.731 19077-20272/io.sopo I/cr_LibraryLoader: Expected native library version number "51.0.2704.81", actual native library version number "51.0.2704.81"
03-23 03:53:49.566 19077-19088/io.sopo W/Ads: There was a problem getting an ad response. ErrorCode: 0
03-23 03:53:49.569 19077-19077/io.sopo W/Ads: Failed to load ad: 0
这是我的代码(btw测试设备ID已被编辑为XXXXXXXXXXXXXXXXXXXXXXXX以隐藏它以防万一):
NativeExpressAdView adView = (NativeExpressAdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder() .addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXX").build();
adView.setVideoOptions(new VideoOptions.Builder()
.setStartMuted(true)
.build());
VideoController vc = adView.getVideoController();
vc.setVideoLifecycleCallbacks(new VideoController.VideoLifecycleCallbacks() {
public void onVideoEnd() {
// Here apps can take action knowing video playback is finished
// It's always a good idea to wait for playback to complete before
// replacing or refreshing a native ad, for example.
super.onVideoEnd();
}
});
adView.loadAd(request);
XML代码:
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/adView"
android:layout_width="wrap_content"
ads:adUnitId="@string/ad_unit_id"
android:layout_height="wrap_content"
ads:adSize="360x320"/>
但是,相同的代码适用于 adUnitId = ca-app-pub-3940256099942544/2177258514
build.gradle 文件:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
/* many other libraries over here */
compile 'com.google.android.gms:play-services-appindexing:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
testCompile 'junit:junit:4.12'
}
repositories {
mavenCentral();
}
apply plugin: 'com.google.gms.google-services'
任何人都知道为什么会出现此错误?请帮忙。