混淆
build.gradle配置
buildTypes {
release {
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'pro.txt'
}
debug {
zipAlignEnabled false
minifyEnabled false
}
}
minifyEnabled true 时才会混淆的
zipAlignEnabled 说是压缩,加不加打包出的包一样大
生成release apk 就是打包的项目的
proguard-android.txt 位于\sdk\tools\proguard下
pro.txt可随意命令,添加自定义的配置
多dex
导入包 android-support-multidex.jar
位于sdk\extras\android\support\multidex\library\libs下。
com.android.support:support-v4 高版本已包含了。
使用
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.andyidea.guidedemo"
minSdkVersion 17
targetSdkVersion 19
multiDexEnabled true
}
项目的application需要添加以下方未能
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
或直接继承MultiDexApplication 源码如下
public class MultiDexApplication extends Application {
public MultiDexApplication() {
}
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
亲测使用不断的向应用中新用jar库
测试方法数 Overall method count: 77421
在配置中不添加 multiDexEnabled true 打包会出错
添加后 打出的包
$ gradlew assemble
$ java -jar path\to\build\jar\dex-method-counts.jar path\to\App.apk
为避免多次下载gradle可以修改 dex-method-counts-master\gradle\wrapper\gradle-wrapper.properties 中的 distributionUrl 为你android项目的一致