标题翻译
Didn't find class AdView
问题
build.gradle
...dependencies {api ('com.google.android.gms:play-services-ads:16.0.0'){force = true}api fileTree(dir: 'libs', include: ['*.jar'])}
layout.xml
...<com.google.android.gms.ads.AdViewandroid:id="@+id/banner_ad"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_alignParentBottom="true"app:adSize="FULL_BANNER"app:adUnitId="ca-app-pub-xxx/xxx"/>...
Log
03-16 11:32:47.006 E/AndroidRuntime(2784): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdView" on path: DexPathList[[zip file ...
英文翻译
I want to add AdMob in my application but the AdView class is not found in my application
build.gradle
...dependencies {api ('com.google.android.gms:play-services-ads:16.0.0'){force = true}api fileTree(dir: 'libs', include: ['*.jar'])}
layout.xml
...<com.google.android.gms.ads.AdViewandroid:id="@+id/banner_ad"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_alignParentBottom="true"app:adSize="FULL_BANNER"app:adUnitId="ca-app-pub-xxx/xxx"/>...
Log
03-16 11:32:47.006 E/AndroidRuntime(2784): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdView" on path: DexPathList[[zip file ...
答案1
得分: 0
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
Also see here: https://stackoverflow.com/questions/34963633/
英文翻译
dependencies {compile 'com.google.android.gms:play-services-ads:8.4.0'}
Also see here: https://stackoverflow.com/questions/34963633/
答案2
得分: 0
在应用的 Gradle 中添加以下内容:
implementation 'com.google.firebase:firebase-ads:18.3.0'
然后,在布局文件中添加以下代码:
<com.google.android.gms.ads.AdViewandroid:id="@+id/adView"android:layout_width="wrap_content"android:layout_height="wrap_content"ads:adSize="BANNER"ads:adUnitId="@string/ad_unit_id"></com.google.android.gms.ads.AdView>
英文翻译
Add below in app Gradle
implementation 'com.google.firebase:firebase-ads:18.3.0'
Then,
<com.google.android.gms.ads.AdViewandroid:id="@+id/adView"android:layout_width="wrap_content"android:layout_height="wrap_content"ads:adSize="BANNER"ads:adUnitId="@string/ad_unit_id"></com.google.android.gms.ads.AdView>
专注分享java语言的经验与见解,让所有开发者获益!

评论