[英]Caused by: java.lang.ClassNotFoundException - multidex not work properly
我已经在Android应用程序项目中安装了multidex解决方案,在“ Google Play开发”中,人们会遇到如下错误:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:2591)
at android.app.ActivityThread.access$1700 (ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1450)
at android.os.Handler.dispatchMessage (Handler.java:110)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:5398)
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:940)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:756)
at dalvik.system.NativeStart.main (Native Method)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass (ClassLoader.java:497)
at java.lang.ClassLoader.loadClass (ClassLoader.java:457)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:2586)
据我所知,我已经正确安装了multidex(已阅读有关此错误和multidex的其他资料)
我所做的事情:
gradle文件:
android {defaultConfig {multiDexEnabled true} dexOptions {javaMaxHeapSize“ 2048M”}}
依赖项{编译'com.android.support:multidex:1.0.1'}
是。 我使用proguard。
更新清单,例如:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
You need to follow this steps if problem with your MultiDex then it resolve:
Step 1: Add dependency to your app level build.gradle.
defaultConfig {
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.2'
}
step 2: You need to create application class.
public class MyApplication extends Application {
@Override
public void onCreate() {
MultiDex.install(this);
super.onCreate();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
step 3: You need to Configure MyApplication class to Manifest file.
<application
android:name=".MyApplication "
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
</application>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.