android发布大于调试apk的apk [英] android release apk bigger than debug apk
问题描述
我正在使用proguard来减小我的apk大小.调试apk从90mb减少到55mb,但是签名apk为71mb.这是我的build.gradle代码:
I'm using proguard to reduce my apk size. The debug apk reduce from 90mb to 55mb, but the signed apk is 71mb. Here is my build.gradle code:
apply plugin: 'com.android.application'
android {
signingConfigs {
XXXX {
keyAlias 'xxxx'
keyPassword 'xxxx'
storeFile file('/Users/xxxx.jks')
storePassword 'xxxxxx'
}
}
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 14
targetSdkVersion 22
versionCode 61
versionName "4.1.8.1"
multiDexEnabled true
signingConfig signingConfigs.XXXX
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.XXXX
}
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.XXXX
}
}
productFlavors {
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
和
repositories {
mavenLocal()
maven {
name "jcenter"
url "http://jcenter.bintray.com/"
}
}
dependencies {
...
}
推荐答案
进一步解释 sosite的答案,看来这仅当比较通过运行"或调试"为特定设备(即使未启用即时运行")而构建的debug
apk而不是通过构建">构建APK"(对于任何受支持的设备)构建的debug
apk时,才会发生.
Further explaining sosite's answer, it seems that this happens only if comparing a debug
apk built via Run or Debug meant for a specific device (even without Instant Run enabled) instead of a debug
apk built via Build > Build APK (for any supported device).
通过 Build APK 构建的任何变体(甚至是debug
本身)都将包含该变体的所有资源.此外, Run/Debug apk包括特定于该单个设备的预编译类,而 Build APK 则仅包括一些常规的预编译类,编译器认为这些类是安全的.所有受支持的设备-仅在安装apk时才在设备本身中进行完全解密.
Any variant (even debug
itself) built via Build APK will include all the resources for that variant. Also, the Run/Debug apk includes pre-dexed classes specific for that single device, while Build APK ones includes only some general pre-dexed classes that the compiler determines safe for all supported devices - the full dexing only occurs in the device itself, when the apk is installed.
对于相同项目和也可以作为html ).
I've zipdiff-ed an apk generated via Debug with another via Build APK for the same variant of the same project and published the simplified output for demonstration (also available as html).
这篇关于android发布大于调试apk的apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!