java.lang.ClassNotFoundException仅在android 4.4上崩溃应用程序

时间:2017-06-20 03:09:04

标签: android

我在设备android 5.0上构建文件APK,之后我使用设备4.4安装然后崩溃。 这个日志:

java.lang.RuntimeException: Unable to instantiate application jp.gmh.app365plus.ChatApplication: java.lang.ClassNotFoundException: Didn't find class "jp.gmh.app365plus.ChatApplication" on path: DexPathList[[zip file "/data/app/jp.gmh.app365plus-1.apk"],nativeLibraryDirectories=[/data/app-lib/jp.gmh.app365plus-1, /vendor/lib, /system/lib]]
                                                               at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
                                                               at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4554)
                                                               at android.app.ActivityThread.access$1600(ActivityThread.java:161)
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                               at android.os.Looper.loop(Looper.java:157)
                                                               at android.app.ActivityThread.main(ActivityThread.java:5356)
                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                               at java.lang.reflect.Method.invoke(Method.java:515)
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
                                                               at dalvik.system.NativeStart.main(Native Method)
                                                            Caused by: java.lang.ClassNotFoundException: Didn't find class "jp.gmh.app365plus.ChatApplication" on path: DexPathList[[zip file "/data/app/jp.gmh.app365plus-1.apk"],nativeLibraryDirectories=[/data/app-lib/jp.gmh.app365plus-1, /vendor/lib, /system/lib]]
                                                               at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
                                                               at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
                                                               at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
                                                               at android.app.Instrumentation.newApplication(Instrumentation.java:993)
                                                               at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
                                                               at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4554) 
                                                               at android.app.ActivityThread.access$1600(ActivityThread.java:161) 
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325) 
                                                               at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                               at android.os.Looper.loop(Looper.java:157) 
                                                               at android.app.ActivityThread.main(ActivityThread.java:5356) 
                                                               at java.lang.reflect.Method.invokeNative(Native Method) 
                                                               at java.lang.reflect.Method.invoke(Method.java:515) 
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
                                                               at dalvik.system.NativeStart.main(Native Method) 

这是类错误

public class ChatApplication extends MultiDexApplication {
    public static Context context;
    private Query query = null;
    private static ChatApplication instance;
    private Socket mSocket;
    private RxBus bus;
    private int version;
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        RealmConfiguration config = new RealmConfiguration.Builder(getApplicationContext())
                .name("arubaitodb.realm")
                .deleteRealmIfMigrationNeeded()
                .build();
        Realm.setDefaultConfiguration(config);
        FLog.setMinimumLoggingLevel(FLog.VERBOSE);
        Set<RequestListener> listeners = new HashSet<>();
        listeners.add(new RequestLoggingListener());

        ImagePipelineConfig frescoConfig = ImagePipelineConfig.newBuilder(getApplicationContext()) .setDownsampleEnabled(true).build();
        DraweeConfig draweeConfig = DraweeConfig.newBuilder()
                .build();
        Fresco.initialize(this, frescoConfig, draweeConfig);
        version = MyUltils.convertIntVersion(BuildConfig.VERSION_NAME);
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    public static ChatApplication get() {
        return instance;
    }
//
//    public RxBus bus() {
//        return bus;
//    }
    public void createSocket(){
        IO.Options opts = new IO.Options();
        opts.forceNew = true;
        opts.query = "token=" + ArubaitoGlobal.token;
        try {
            mSocket = IO.socket(Constant.URL_HOST, opts);
//            mSocket.connect();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    public Socket getSocket() {
        return mSocket;
    }
    public int getVersion(){
        return version;
    }
}

但偶尔会发生这种情况,我建造了10次然后大约3次撞击并成功存在。 我不知道原因?请。

0 个答案:

没有答案