我最近開始在Android應用程序開發中,並且在嘗試在我的應用程序中加載橫幅時,我在logcat中出現以下錯誤。AdMob Banner不適用於移動數據
03-02 17:30:58.509: I/Ads(12181): Use AdRequest.Builder.addTestDevice("My device ID") to get test ads on this device.
03-02 17:30:58.509: I/Ads(12181): Starting ad request.
03-02 17:30:58.799: W/Ads(5515): Error while connecting to ad server: failed to connect to googleads.g.doubleclick.net/74.125.225.250 (port 80) after 60000ms: isConnected failed: ENETUNREACH (Network is unreachable)
03-02 17:30:58.799: W/Ads(12181): There was a problem getting an ad response. ErrorCode: 2
03-02 17:30:58.939: I/Ads(12181): Scheduling ad refresh 60000 milliseconds from now.
03-02 17:30:58.939: W/Ads(12181): Failed to load ad: 2
它只是發生在某些設備(主要是在搭載Android 4.1果凍豆),並只對移動數據(使用墨西哥的Telcel),它適用於無線網絡的預期。
我的xml和java代碼與AdMob實施指南相同。
layout.xml旗幟
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="My Add Unit Id (Hidden)" />
MainActivity onCreate方法
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
希望你能幫助我解決這個問題。