I have used
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
...
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
...
}
in the app
-level build.gradle
and
<manifest package="com.example"
...
<application
android:name=".AppContext"
...
>
>
in the manifest
for the long time because of my app definitely references more than 64K methods. Now I have changed it to fresh SDK and multidex
lib under Android Studio 3.3.2
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
...
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
...
}
and app have began to crash when installing on all available Android 4.X devices. Most crashes has stacktrace like below:
java.lang.RuntimeException:
at android.app.ActivityThread.installProvider (ActivityThread.java:5236)
at android.app.ActivityThread.installContentProviders (ActivityThread.java:4828)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4711)
at android.app.ActivityThread.access$1600 (ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1368)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:146)
at android.app.ActivityThread.main (ActivityThread.java:5602)
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:1283)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1099)
at dalvik.system.NativeStart.main (Native Method)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass (ClassLoader.java:497)
at java.lang.ClassLoader.loadClass (ClassLoader.java:457)
at android.app.ActivityThread.installProvider (ActivityThread.java:5221)
The only way I have found to solve the problem is to exclude
// compile 'com.android.support:multidex:1.0.3'
from app
-level build.gradle
and changing
public class AppContext extends Application {
...}
to
public class AppContext extends MultiDexApplication {
...}
Is it a bug in build tools 27.x.x
or what!?