Reputation: 79
I have a project with two modules. It exists a default configuration of build.gradle:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
And I want to add a different configuration (proguard and minifying) for debug compilation as follow:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles 'proguard-rules-debug.pro'
}
}
When I put this code in my project, it doesn't compile. The log show a message error for each reference to another module:
Error:(37, 42) error: package com.example does not exist
Full Gradle configuration of the two modules.
The app module:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
...
}
}
apply plugin: 'com.android.application'
...
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.3"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
}
repositories {
maven {
...
}
}
repositories{
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
...
dependencies {
...
}
The library module:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
...
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
...
}
Upvotes: 1
Views: 1450
Reputation: 161
I would try the following:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules-debug.pro'
}
}
Alternatively did you try putting the rules files into the build-types folders? You could put the proguard-rules.pro
file into the build-types/release folder and the proguard-rules-debug.pro
file into the build-types/debug folder.
Upvotes: 2