【发布时间】:2015-09-13 06:58:57
【问题描述】:
我让 proguard 正常工作,但问题是我的项目中有一个库项目,所以当 proguard 发挥作用时,库无法识别类(反之亦然)。
当我有一个库项目时如何正确使用proguard?如何使两个项目正确链接到彼此的类? 非常感谢任何帮助。
这是我的应用程序的构建文件:
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'
}
这是我的库的构建文件:
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+'
}
【问题讨论】:
-
你能发布你的 build.gradle 用于主项目和库项目吗?
-
我认为您不需要为您的库项目启用 proguard。您的主应用程序启用了 proguard,它也会混淆您的库项目文件。在这里查看:stackoverflow.com/questions/10982344/…
-
试过了,库代码不会混淆因此会产生错误..
标签: android android-studio proguard