当最小sdk低于5.0时启用multidex创建singledex
但是,当min sdk为5.0及更高版本时,它将创建多个dex文件。
重现步骤:
appcompat
和RecyclerView库输出:将在构建文件夹
输出:将在构建文件夹
在5.0及更高版本中未达到64k限制时,有什么方法可以避免创建多个dex?
最佳答案
您需要禁用InstantRun来禁用multidex,因为如果最小sdk设置为21或更高,则会自动配置它。
您可以从documentation读取它:
Multidex support for Android 5.0 and higher
Android 5.0 (API level 21) and higher uses a runtime called ART which natively supports loading multiple DEX files from APK files. ART performs pre-compilation at app install time which scans for classesN.dex files and compiles them into a single .oat file for execution by the Android device. Therefore, if your minSdkVersion is 21 or higher, you do not need the multidex support library.For more information on the Android 5.0 runtime, read ART and Dalvik.
Note: While using Instant Run, Android Studio automatically configures your app for multidex when your app's
minSdkVersion
is set to 21 or higher. Because Instant Run only works with the debug version of your app, you still need to configure your release build for multidex to avoid the 64K limit.
关于android - 当min sdk为5.0以下时,启用multidex创建singledex,而当min sdk为5.0以上时,则启用multidex。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46603037/