App crashes after reinstall on emulator since FileProvider Class was not found

后端 未结 2 1687
栀梦
栀梦 2021-01-19 01:01

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

相关标签:
2条回答
  • 2021-01-19 01:25

    If you use Android 5.0 or lower in your emulator (api level 21), then add the multidex support library to your project:

    1. 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
          }
          ...
      }
      
      1. if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:

      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

    0 讨论(0)
  • 2021-01-19 01:27

    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"
    
    0 讨论(0)
提交回复
热议问题