如何解决改装崩溃 android pre android 5 台设备

How to solve retrofit crash android pre android 5 devices

我正在为许多 android 项目使用改造。我开始在 android 4 devices.When 上崩溃 我尝试创建如下改造对象。

Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(getString(R.string.endpoint))
            .addConverterFactory(GsonConverterFactory.create(gson))
            //.setConverter(new GsonConverter(gson))
            //.setClient(new OkClient(okHttpClient))
            .build();
        return retrofit.create(WS.class);

华为登顶android 4.4.设备打印此错误

03-24 11:39:24.684 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zze.zzi
03-24 11:39:24.684 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve virtual method 574: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
03-24 11:39:24.704 2255-2255/com.mobisem.matkit I/GMPM: App measurement is starting up, version: 8487
03-24 11:39:24.704 2255-2255/com.mobisem.matkit I/GMPM: To enable debug logging run: adb shell setprop log.tag.GMPM VERBOSE
03-24 11:39:24.749 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
03-24 11:39:24.749 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
03-24 11:39:24.749 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve interface method 19771: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
03-24 11:39:24.749 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
03-24 11:39:24.749 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve interface method 19775: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Platform.get, referenced from method retrofit2.Retrofit$Builder.<init>
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64784: Lretrofit2/Platform;.get ()Lretrofit2/Platform;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to find class referenced in signature (Lretrofit2/Platform;)
03-24 11:39:24.809 2255-2255/com.mobisem.matkit E/dalvikvm: Could not find class 'retrofit2.BuiltInConverters', referenced from method retrofit2.Retrofit$Builder.<init>
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve new-instance 9323 (Lretrofit2/BuiltInConverters;) in Lretrofit2/Retrofit$Builder;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.addCallAdapterFactory
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.addConverterFactory
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.baseUrl
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to find class referenced in signature (Lokhttp3/HttpUrl;)
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.baseUrl
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit E/dalvikvm: Could not find class 'okhttp3.OkHttpClient', referenced from method retrofit2.Retrofit$Builder.build
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve new-instance 9290 (Lokhttp3/OkHttpClient;) in Lretrofit2/Retrofit$Builder;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Platform.defaultCallbackExecutor, referenced from method retrofit2.Retrofit$Builder.build
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve virtual method 64783: Lretrofit2/Platform;.defaultCallbackExecutor ()Ljava/util/concurrent/Executor;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Platform.defaultCallAdapterFactory, referenced from method retrofit2.Retrofit$Builder.build
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve virtual method 64782: Lretrofit2/Platform;.defaultCallAdapterFactory (Ljava/util/concurrent/Executor;)Lretrofit2/CallAdapter$Factory;
03-24 11:39:24.809 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.callFactory
03-24 11:39:24.809 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.814 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.callbackExecutor
03-24 11:39:24.814 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.814 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to find class referenced in signature (Lokhttp3/OkHttpClient;)
03-24 11:39:24.814 2255-2255/com.mobisem.matkit I/dalvikvm: Could not find method retrofit2.Utils.checkNotNull, referenced from method retrofit2.Retrofit$Builder.client
03-24 11:39:24.814 2255-2255/com.mobisem.matkit W/dalvikvm: VFY: unable to resolve static method 64816: Lretrofit2/Utils;.checkNotNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
03-24 11:39:24.814 2255-2255/com.mobisem.matkit W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x415bec50)

很烦人!

经过多次搜索,我找到了解决方案。当我使用 MultiDexApplication 更改我的应用程序 class 超类型应用程序时,它起作用了。有效。它与改造没有直接关系。这是一个 gradle 和 dex 问题。

使用 Retrofit 1.9 版和 okhttp 2.3 版,适用于所有设备。虽然改造 2.0 承诺会更快,但已经更改 lot.Sticking 1.9 不会有任何并发​​症。