Can I enable multidex in Android debug build only?

后端 未结 4 1325
南方客
南方客 2021-01-07 23:22

Dears, I read in many blog posts that multidex apps startup is slower than normal apps. My app uses a lot of libraries that exceed 64k methods so I use multidex. But w

4条回答
  •  生来不讨喜
    2021-01-07 23:47

    Instead of enabling multidex only for debug, you can change your min sdk version to 21 only for debug so gradle can speed up dexing with ART:

    android {
        productFlavors {
            // Define separate dev and prod product flavors.
            dev {
                // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
                // to pre-dex each module and produce an APK that can be tested on
                // Android Lollipop without time consuming dex merging processes.
                minSdkVersion 21
            }
            prod {
                // The actual minSdkVersion for the application.
                minSdkVersion 14
            }
        }
              ...
        buildTypes {
            release {
                runProguard true
                proguardFiles getDefaultProguardFile('proguard-android.txt'),
                                                     'proguard-rules.pro'
            }
        }
    }
    dependencies {
      compile 'com.android.support:multidex:1.0.0'
    }
    

    http://developer.android.com/tools/building/multidex.html

提交回复
热议问题