【发布时间】:2017-10-04 18:42:56
【问题描述】:
大约 24 小时前,我在 AdMob 控制台中设置了横幅广告。它没有连接到火力基地。我确实得到了测试横幅,但还没有实时横幅。
我请求横幅的活动:
private void showStartFragment(){
//initialize AdMob
MobileAds.initialize(this, "ca-app-pub-XXXXXXXXXXXXXXXXX~YYYYYYYYYY");
//request Banner
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice("MY_TEST_DEVICE_ID") //my Lenovo K6
.build();
mAdView.loadAd(adRequest);
//listener for observing
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Log.i("admob", "onAdLoaded");
}
@Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Log.i("admob", "onAdFailedToLoad");
Log.i("admob", "error code " + Integer.toString(errorCode));
}
@Override
public void onAdOpened() {
// Code to be executed when an ad opens an overlay that
// covers the screen.
Log.i("admob", "onAdOpened");
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
Log.i("admob", "onAdLeftApplication");
}
@Override
public void onAdClosed() {
// Code to be executed when when the user is about to return
// to the app after tapping on an ad.
Log.i("admob", "onAdClosed");
}
});
我的布局文件摘录:
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-XXXXXXXXXXXXXXX/YYYYYYYYY"
android:layout_marginTop="50dp">
</com.google.android.gms.ads.AdView>
我的 build.gradle(app):
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion '25.0.0'
signingConfigs {
debug {
...
}
}
defaultConfig {
applicationId "mysample.app.de.hooorray"
minSdkVersion 15
targetSdkVersion 22
versionCode 4
versionName "1 Beta"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-ads:10.2.0'
//compile 'com.google.firebase:firebase-ads:11.4.2'
compile 'com.facebook.android:facebook-android-sdk:4.8.0'
compile 'com.twitter.sdk.android:twitter:3.0.0'
compile project(':BaseGameUtils')
compile project(':vksdk_library')
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
我已经尝试过的:
- 通过 test-device-id 或 test-banner-id 添加测试用例 -> WORKS!
- 编译了不同的库(
com.google.android.gms:play-services-ads:10.2.0/11.4.2和com.google.firebase:firebase-ads:11.4.2)-> 不起作用 - 将三重检查的 ADMOB_APP_ID 和 ADMOB_AD_UNIT_ID 硬编码到类/布局文件中 -> 不起作用
- 在不同的真实设备上试过 -> 不起作用
- 构建并安装了我的应用程序的发布版本 -> 不起作用
如果我不使用测试示例,我在 Logat 中总是会得到什么:
10-04 20:09:41.228 29844-29935/? W/Ads: The Google Mobile Ads SDK will not integrate with Firebase. Admob/Firbase integration requires the latest Firebase SDK jar, but Firebase SDK is either missing or out of date
10-04 20:09:42.292 29844-29844/? I/admob: onAdFailedToLoad
10-04 20:09:42.292 29844-29844/? I/admob: error code 0
根据Google Docs 错误代码“0”代表ERROR_CODE_INTERNAL_ERROR - 内部发生了一些事情;例如,从广告服务器收到无效响应。
我读过几次,可能需要几个小时,新设置的广告才会上线,但现在 24 小时已经过去了。我还读到,在某些地区可能没有横幅广告可用,但我无法想象这在德国应该是个问题。
我很感激任何提示!提前谢谢!!
【问题讨论】:
-
你能发布你的应用 Gradle 吗?
-
@Drew,谢谢 4 快速回复。我更新了我的 build.gradle,刚刚的样子。
-
当您使用最新的 Google 广告依赖项
compile 'com.google.android.gms:play-services-ads:11.4.0'时会发生什么? -
与上述相同的 Logcat 消息:“10-04 21:12:42.497 32627-32627/popthebubbleretro.cucoo.de.popthebubbleretro I/admob: onAdFailedToLoad 10-04 21:12:42.497 32627 -32627/popthebubbleretro.cucoo.de.popthebubbleretro I/admob: 错误代码 0"
-
该应用无需发布或签名即可显示实时广告。