【发布时间】:2016-08-05 16:39:53
【问题描述】:
我有一个引用 ~ 100K 方法的应用,其中 min Sdk = 16
这里有两种组装方式:
- Proguard 将这组方法缩减到只有 44K 个方法
- 使用多敏捷
现在我有一些常见的用例:
- 在模拟器和设备上运行和调试
- 要求尽可能快
- 进行测试(集成和 UI)
- 它需要运行(我在使用 MultiDex 运行 Espresso 时遇到了一些问题)
- 制作 Prod APK
- 它要求尽可能可靠和缩小
你们对组装策略有什么建议吗?
3/ 产品
- 使用 Proguard 减小 APK 大小
- 使用 Proguard 进行混淆
- 尽量不要使用 Multidex(可能会失败)
2/ 测试
- 使用 minSdkVersion 21(我读到从 21 开始启用 pre-dexing,这样可以节省时间)
- ???
1/ 调试
- 使用 minSdkVersion 21(我读到从 21 开始启用 pre-dexing,这样可以节省时间)
- ???
这是 Gradle 文件:
productFlavors {
dev {
minSdkVersion 21
multiDexEnabled ???
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION
multiDexEnabled false
}
}
defaultConfig {
applicationId "xxxx"
targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION
minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION
versionCode ANDROID_BUILD_VERSION_CODE
versionName ANDROID_BUILD_APP_VERSION_NAME
}
buildTypes {
release {
debuggable false
ext.enableCrashlytics = true
renderscriptOptimLevel 3
signingConfig android.signingConfigs.release
zipAlignEnabled true
minifyEnabled true
// shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
renderscriptOptimLevel 3
applicationIdSuffix ".debug"
versionNameSuffix "debug"
minifyEnabled false
}
}
【问题讨论】:
标签: android gradle proguard android-productflavors android-multidex