gpt4 book ai didi

android - 当min sdk为5.0以下时,启用multidex创建singledex,而当min sdk为5.0以上时,则启用multidex。

转载 作者:行者123 更新时间:2023-12-03 05:52:59 24 4
gpt4 key购买 nike

当最小sdk低于5.0时启用multidex创建singledex
但是,当min sdk为5.0及更高版本时,它将创建多个dex文件。

重现步骤:

  • 创建项目并添加appcompat和RecyclerView库
  • 将min sdk设置为14并构建项目
    输出:将在构建文件夹
  • 中创建单个dex。
  • 将min sdk设置为21并构建项目
    输出:将在构建文件夹
  • 中创建多个dex文件

    在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/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com