问题
My application is a custom class that extends MultiDexApplication.
public class CustomApp extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
//TODO
}
}
In my AndroidManifest.xml :
<application
android:name=".helper.CustomApp"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="${app_name}"
android:largeHeap="true"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:allowBackup, android:label">
When I try to run the apk on a samsung s6 (API 7.0), everything works fine. BUT, when I try to run it on a THOMSON (API 4.2.2), I get this error :
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application me.blu.app.helper.CustomApp: java.lang.ClassNotFoundException: Didn't find class "me.blu.app.helper.CustomApp" on path: DexPathList[[zip file "/data/app/me.blu.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/me.blu.app-1, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
So this I did that - I created a multidex-config.txt and added this line :
me/blu/app/helper/CustomApp.class
This file is located right next to my build.gradle file as needed.
Then I added this multiDexKeepFile file('multidex-config.txt')
in my two builTypes but ALSO below multiDexEnabled true
.
It's still not working. I would higly appreciate some help ^^
Thanks.
回答1:
I once facing with the same problems eventhough had adding the multidex. The problem arise whenever apk is running in Android 4.4 Xiaomi (If I remember it correctly). To solution is using MultiDex.install()
in app like this:
public class CustomApp extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Then adding the jumboMode true
in module build.gradle
:
android {
...
dexOptions {
jumboMode = true
}
}
来源:https://stackoverflow.com/questions/46600992/multidexkeepfile-ignored-not-working