I know this question has been asked a million times and yet, I couldn't find the answer to my specific situation. I have a library which has all of the code, and a couple of other modules that import the library.
-project
--mylibrary
---sr/main/java
----co/android/mylibrary
----BaseApp (extends MultidexApp)
--Application1
---sr/main/java
----co/android/app2
-----Android Manifest
--Application2
---sr/main/java
----co/android/app2
-----Android Manifest
And both the manifests use the base app like this.
<application
android:name="co.android.mylibrary.BaseApp"
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme"
tools:replace="android:icon,android:theme, android:allowBackup">
And the build dependencies look like this:
dependencies {
releaseCompile project(path: ':mylibrary', configuration: 'release')
debugCompile project(path: ':mylibrary', configuration: 'debug')
}
My base app's method to initialize multidex:
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
try {
MultiDex.install(this);
}catch (RuntimeException e){}
}
Some of my proguard rules, that I've added at both locations (library and the application). These don't include some rules for 3rd party libraries and some of my own classes.
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View
-keep public class co.android.mylibrary.data.greendao.**{ *; }
So the app runs fine on my s8, but doesn't on some phones like the moto G. They would also run fine if Proguard is enabled and its shrinking resources, like for release builds. Another strange behavior I noticed is that, when I set my breakpoint on some parts of my code and run the release builds (with debuggable set to true), it would break on the s8, but not on the moto.
Why this strange behavior? Another question that I found super similar is unable to instantiate application - ClassNotFoundException. But still no resolution.
This is the complete log of the error. Ignore the package names.
Edit
After changing the way I compile the library on my application, based on suggestiongs from @Mostafa Anter:
compile project(path: ':mylibrary', configuration: 'debug')
It started giving me this error. I have my instant run turned off.