Java.lang.classnotfoundexception: Android.os.asynctask Caused By Admob / Google Play Services?
Solution 1:
OK, looks like it is a problem with one of the versions of Google play Services. See https://code.google.com/p/android/issues/detail?id=81083
Looks like a work around might be to add the following to your Application#onCreate()
:
package acme.com.myAppName;
import android.app.Application;
publicclassMyApplicationextendsApplication
{
@OverridepublicvoidonCreate()
{
// begin addtry {
Class.forName("android.os.AsyncTask");
} catch(Throwable ignore) {
}
// end addsuper.onCreate();
}
}
NB don't forget to configure your Application class in your AndroidManifest.xml
(if you haven't already).
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="acme.com.myAppName.MyApplication" >
...
</application>
Solution 2:
To expand on the answer above, as I didn't know what the Application#onCreate() was and hadn't already implement one in my app. What I did was create a new Class in my app with the following:
package acme.com.myAppName;
import android.app.Application;
publicclassmyApplicationextendsApplication
{
@OverridepublicvoidonCreate()
{
try
{
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore){}
super.onCreate();
}
}
Then I updated my AndroidManifest.xml file with android:name="acme.com.myAppName.myApplication"
to use the myApplication
class, like so:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="acme.com.myAppName.myApplication" >
...
</application>
Solution 3:
Same problem here, since 23/11 I got about 1500 ClassNotFoundException errors on 2.x clients, with an increasing trend. The app was not updated for months, so I agree on your hypothesis about the google play services ota update
Solution 4:
I surrounded my adview.loadAd(adrequest);
with a try catch block and this has solved my issue.
Here is the code snippet :
try
{
adview.loadAd(adRequest);
}
catch(java.lang.NoClassDefFoundError ncdfe)
{
ncdfe.printStackTrace();
Log.d("AD ERROR", "ERROR LOADING AD");
}
Post a Comment for "Java.lang.classnotfoundexception: Android.os.asynctask Caused By Admob / Google Play Services?"