我正在使用带有 Google Play Services 7.5、Android 21 和 Support v4 库的 proguard 编译一个项目。如果我用 android studio 编译它,我的方法计数比用 eclipse 编译它的要高。我在两个程序生成的两个 apk 中使用了一个名为 dex-method-count 的程序,我发现这就是原因:
AndroidStudio+gradle:
support: 5416
v4: 2755
app: 594
content: 33
graphics: 96
drawable: 96
internal: 74
view: 74
media: 123
session: 60
os: 13
text: 17
util: 166
view: 1024
accessibility: 204
widget: 615
v7: 2661
app: 232
appcompat: 1
internal: 1757
app: 77
text: 3
transition: 1
view: 628
menu: 536
widget: 1047
view: 24
widget: 647
日食+蚂蚁:
support: 2073
v4: 2073
app: 549
content: 21
media: 123
session: 60
os: 11
util: 157
view: 757
accessibility: 204
widget: 455
正如您在第一个选项中看到的那样,它添加了许多来自支持 v7 的方法,为什么?如何避免这种情况?
谢谢
PD:我的库和应用程序的构建 gradle 文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 'Google Inc.:Google APIs:22'
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 10
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.google.android.gms:play-services:7.5.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
应用程序:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:22'
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.launcher"
minSdkVersion 10
targetSdkVersion 10
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile project(':caponateLibrary')
compile 'com.google.android.gms:play-services:7.5.0'
}