MultiDexKeepFile ignored / not working

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 apk on samsung s6 (API 7.0), everything works fine. BUT, when I try to run it on 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, I did that - I created the multidex-config.txt file and added this line:

 me/blu/app/helper/CustomApp.class 

This file is next to my build.gradle file as needed.

Then I added this multiDexKeepFile file('multidex-config.txt') to my two builTypes, but ALSO below multiDexEnabled true .

It still does not work. I would greatly appreciate some help ^^

Thanks.

+1
source share
1 answer

Once I faced the same problems as when adding multidex. The problem occurs whenever apk works in Android 4.4 Xiaomi (if I remember it correctly). For the solution, MultiDex.install() in the application:

 public class CustomApp extends Application { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } } 

Then adding jumboMode true to the build.gradle module :

 android { ... dexOptions { jumboMode = true } } 
0
source

Source: https://habr.com/ru/post/986678/


All Articles