我让proguard正常工作,但问题是我的项目中有一个库项目,所以当proguard发挥其魔力时,库无法识别类(反之亦然)。
如果我有图书馆项目,如何正确使用proguard?如何让两个项目正确地链接到彼此的类? 任何帮助都是很有帮助的人。
这是我的App的构建文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.ex.test"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:21.0.2'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.android.support:support-annotations:21.0.2'
compile 'com.android.support:support-v4:21.0.2'
compile project(':chatinglibrary')
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.afollestad:material-dialogs:0.7.6.0'
}
这是我的lib的构建文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.firebase:firebase-client-android:2.0.3+'
}
答案 0 :(得分:0)
你必须保持每个libs像proguard一样
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
有些图书馆有特殊的保护措施来保持不受欢迎