我无法使用Google Admob在我的应用中看到广告。
这是LogCat
输出:
01-22 02:11:21.335: I/Ads(626): Request scenario: Online server request.
01-22 02:11:21.666: I/Ads(626): Invalid response code: 499
01-22 02:11:21.666: D/webviewglue(626): nativeDestroy view: 0x2a206860
01-22 02:11:21.675: I/Ads(626): onFailedToReceiveAd(There was an internal
error.)
我可以做些什么来解决这个问题?
private AdView adMobView;
private AdRequest adMobRequest;
@Override
public void onCreate(Bundle savedInstanceState) {
....
startAds();
.....
}
private void startAds () {
//AdMob
adMobView = new AdView(this, AdSize.BANNER, ADMOB_ID);
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.addView(adMobView);
adMobRequest = new AdRequest();
adMobView.loadAd(adMobRequest);
}
MANIFEST XML
...
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
...
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
..
我在设备Galaxy S4和Android模拟设备上进行了测试。
今天在AdMob统计数据中,我总共获得了33个请求0展示次数,但昨天我已经累计了77次请求,只有1次展示。我不知道问题是在我的代码中,还是Google不向我发送广告。
但是,如果我将测试模式设置为true,则会收到与粘贴在顶部相同的错误:(
答案 0 :(得分:0)
private AdView adMobView;
private AdRequest adMobRequest;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
(...)
startads();
}
private void startAds () {
//AdMob
adMobView = new AdView(this, AdSize.BANNER, ADMOB_ID);
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.addView(adMobView);
adMobRequest = new AdRequest();
adMobView.loadAd(adMobRequest);
}
XML MANIFEST:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
没有