问题
My projects build.gradle looks like following:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "..."
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':androKnife')
}
And my androKnife
module does have it's own proguard file. How can I make my main project use this file as well?
Is there some way to auto merge all proguard files of all modules, if I compile a project? Is there another way a module can specify it's proguard rules and a project can inherit it?
回答1:
The solution is to add following line to the libraries build.gradle
: consumerProguardFiles 'proguard-rules.pro'
So my androKnife library looks like following:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
}
}
dependencies {
...
}
回答2:
So, main module proguard
code, likes this:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'main_proguard-rules.pro'
}
}
Who does know the principle of the inner relationship of proguardFiles
? Auto merged or Overrided when has the same proguard code?
来源:https://stackoverflow.com/questions/30783407/proguard-also-use-proguard-files-from-modules