抛出java.lang.ClassNotFoundException:android.os.AsyncTask造成的AdMob /谷歌播放服务? [英] java.lang.ClassNotFoundException: android.os.AsyncTask caused by AdMob / Google Play Services?

查看:532
本文介绍了抛出java.lang.ClassNotFoundException:android.os.AsyncTask造成的AdMob /谷歌播放服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自2014年11月21日我收到数以百计的崩溃报告与下面的堆栈。

仅发生在API级别10个设备崩溃(应用程序支持9 +)

应用程序的非常相同的版本已经在几个星期罚款运行崩溃开始前。这使我认为这个问题是由被推到最近的Andr​​oid 2.3设备的一些过度的空气更新引起的。

我使用AdMob中介(也就是现在的谷歌Play服务库的一部分)在我的应用程序和其他一些广告网络SDK。

我怀疑谷歌Play服务库是导致飞机失事的原因,因为它是应用程序的,据我所知,可能是过度的空气更新的唯一部分(这不会是第一次一车更新会导致崩溃)。

它是可能的,如由OP的输入回答<一href=\"http://stackoverflow.com/questions/6968744/getting-noclassdeffounderror-android-os-asynctask/7233642#comment42810535_7233642\">here,通过AdMob建立显示横幅广告的可能把整个过程中它是不能够再创建类的新实例的状态线程内部引发未捕获的异常?

有没有人从一个类似的问题最近的痛苦?

  java.lang.NoClassDefFoundError的:com.myapp.MyClassExtendingAsyncTask
在com.myapp.x.run(的SourceFile:417)
在android.os.Handler.handleCallback(Handler.java:587)
在android.os.Handler.dispatchMessage(Handler.java:92)
在android.os.Looper.loop(Looper.java:130)
在android.app.ActivityThread.main(ActivityThread.java:3859)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:507)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:889)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:647)
在dalvik.system.NativeStart.main(本机方法)
抛出java.lang.ClassNotFoundException:引起com.myapp.MyClassExtendingAsyncTask装载机dalvik.system.PathClassLoader [/data/app/com.myapp-1.apk]
在dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
在java.lang.ClassLoader.loadClass(ClassLoader.java:551)
在java.lang.ClassLoader.loadClass(ClassLoader.java:511)
... 10个


解决方案

OK,看起来是与谷歌的播放服务版本之一的一个问题。
见<一href=\"https://$c$c.google.com/p/android/issues/detail?id=81083\">https://$c$c.google.com/p/android/issues/detail?id=81083

看起来像周围的工作可能是以下内容添加到)你的应用#的onCreate(

 包acme.com.myAppName;进口android.app.Application;公共类MyApplication的扩展应用
{
    @覆盖
    公共无效的onCreate()
    {
        //开始加
        尝试{
            的Class.forName(android.os.AsyncTask);
        }赶上(Throwable的忽略){
        }
        //最后添加        super.onCreate();
    }
}

NB不要忘记在配置应用程序类的的Andr​​oidManifest.xml (如果你还没有的话)。

 &lt;应用
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme
    机器人:名字=acme.com.myAppName.MyApplication&GT;
...
&LT; /用途&gt;

Since November 21, 2014 I am receiving hundreds of crash reports with the stack below.

The crash occurs only on API Level 10 devices (the app supports 9+)

The very same version of the app had been running fine over several weeks before the crashes started. This makes me think that the problem is caused by some over-the-air update that was pushed to Android 2.3 devices recently.

I use AdMob mediation (which is now part of the Google Play Services library) and several other ad network SDKs in my app.

I suspect the Google Play Services library to be causing the crash, as it is the only part of the app that, to my knowledge, is likely to be updated over-the-air (and this would not be the first time a buggy update causes crashes).

Is it possible, as mentioned by the OPs answer here, that an uncaught exception triggered inside the thread created by AdMob to display banner ads might put the whole process in a state where it is not able to create new instances of classes anymore?

Has anybody been suffering from a similar issue recently?

java.lang.NoClassDefFoundError: com.myapp.MyClassExtendingAsyncTask
at com.myapp.x.run(SourceFile:417)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3859)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:647)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.MyClassExtendingAsyncTask in loader dalvik.system.PathClassLoader[/data/app/com.myapp-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
... 10 more

解决方案

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;

public class MyApplication extends Application
{
    @Override
    public void onCreate()
    {
        // begin add
        try {
            Class.forName("android.os.AsyncTask");
        } catch(Throwable ignore) {
        }
        // end add

        super.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>

这篇关于抛出java.lang.ClassNotFoundException:android.os.AsyncTask造成的AdMob /谷歌播放服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆