I've recently started in Android App developing and I'm a getting the following error in logcat when trying to load the banner in my app.
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
It only happens in certain devices (Mostly in Android 4.1 Jelly Bean) and only on mobile data (Using Telcel México), it works as expected on WiFi.
My xml and java code is the same as the AdMob implementation guide.
layout.xml banner
<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 Method
@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);
}
Hope you can help me solve this.