【发布时间】:2020-07-11 02:19:03
【问题描述】:
我想在我的项目中使用Google Ads Samples 实现原生广告,但出现错误:
Google 移动广告 SDK 不会与 Firebase 集成。 Admob/Firebase 集成需要最新的 Firebase SDK jar,但 Firebase SDK 缺失或已过期
我不想为这个项目设置 firebase,所以自己导入 Google Mobile Ads SDK。
应用build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "appId"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
return void
}
buildTypes {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
return void
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:19.0.1'
}
我在 Application 类中初始化了 admob:
MobileAds.initialize(this, getString(R.string.admob_app_id));
我检查了带有测试单元广告的 BannerAd,它加载并显示完美。但是包含原生广告单元的活动崩溃了。
有什么建议吗?
【问题讨论】:
标签: android firebase admob integration native