Since a few weeks i am receiving the following crash reports from users
FATAL EXCEPTION: AdWorker #1
java.lang.NoSuchMethodError: java.io.IOException.<init>
at com.google.android.gms.internal.g.f(Unknown Source)
at com.google.android.gms.internal.g.b(Unknown Source)
at com.google.android.gms.internal.e.a(Unknown Source)
at com.google.android.gms.internal.e.a(Unknown Source)
at com.google.android.gms.internal.bq.ac(Unknown Source)
at com.google.android.gms.internal.cg$1.run(Unknown Source)
at com.google.android.gms.internal.ch$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
Other than it has something to do with google ad/cloud services, i had no clue where it comes from. couldn't reproduce it till yesterday i started up a 10 inch emulator and saw immediately the problem. After removing parts of my code i identied to following piece to be the problem.
public void onActivityCreated(Bundle savedInstanceState) {
............
AdView adView = (AdView)getActivity().findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("CED2A4FD2C192C08557081CC37AA9E54")
.build();
adView.loadAd(adRequest);
}
The strange thing is that it only happens on 10 inch devices or up. I tested on various different devices/versions. The problem only occurs on 10 inch devices or bigger. Android versions doesnt matter. 2.2 or 4.4 it keeps crashing.
To my understanding i dont have any different layout folders for specific device sizes. the xml where my ad is defined looks like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/titleContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
<com.viewpagerindicator.TabPageIndicator
android:id="@+id/indicator"
style="@style/tabsbackground"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/adViewContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="@string/adid"
ads:adSize="SMART_BANNER"
android:gravity="bottom"
/>
</LinearLayout>
</LinearLayout>
I tried out different banner sizes. Doesnt help. Removing the ad request code solves the problem, but also removes the advertising. Anyone a clue?
Google Mobile Ads is now offered through Google Play Services 4.0 and this error occurs because the Google Play Services is not available. Most likely you will run into this on Froyo, where there is a special version that can be used.
http://developer.android.com/google/play-services/setup.html
Note: Google Play services 4.0.30 (released November 2013) and newer versions require Android 2.3 or higher. If your app supports Android 2.2, you can continue development with the Google Play services SDK, but must instead install Google Play services for Froyo from the SDK Manager.
http:// android-developers.blogspot.no/2013/10/google-play-services-40.html
With over 97% of devices now running Android 2.3 (Gingerbread) or newer platform versions, we’re dropping support for Froyo from this release of the Google Play services SDK in order to make it possible to offer more powerful APIs in the future. That means you will not be able to utilize these new APIs on devices running Android 2.2 (Froyo).
https://developer.android.com/google/play-services/setup.html#ensure
Important: Because it is hard to anticipate the state of each device, you must always check for a compatible Google Play services APK before you access Google Play services features. For many apps, the best time to check is during the onResume() method of the main activity.
Alernative 1 is to check if Google Play Services is available before using AdView.
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext();
if(status == ConnectionResult.SUCCESS) {
//Success! Do what you want
}
Alernative 2 is to use GoogleAdMobAdsSdk-6.4.1.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With