When I run the app on the emulator it always works on the first try. But when the app is already installed on the emulator it often results in a crash during the start of th
If you use Android 5.0 or lower in your emulator (api level 21), then add the multidex support library to your project:
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
dependencies { compile 'com.android.support:multidex:1.0.1' }
Look at https://developer.android.com/studio/build/multidex.html#mdex-gradle
If you are using androidx
libraries, in AndroidManifest.xml
, change this:
android:name="android.support.v4.content.FileProvider"
to this:
android:name="androidx.core.content.FileProvider"