Background
Recently I've made a new app, and when I tried to generate a signed APK, I've noticed a weird behavior:
- There was no mapping file anywhere in the project's folder.
- When enabling the minimizing flags in the gradle file ("minifyEnabled" and "shrinkResources") , it showed an error:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
Job failed, see logs for details
The problem
Thing is, I didn't add anything special to the project that might cause the Proguard rules not to work. Everything is used in the default way they were set to be.
Here's the app gradle file (replaced some with "...") :
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias '...'
keyPassword '...'
storeFile file(...)
storePassword '...'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId '...'
minSdkVersion 14
targetSdkVersion 25
versionCode 21
versionName "1.21"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// vectorDrawables.useSupportLibrary = true
}
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/LICENSE-FIREBASE_jvm.txt'
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-plus:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
...
}
apply plugin: 'com.google.gms.google-services'
As you can see, it's about the same as the original one.
Here's the project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-rc1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {
url 'https://dl.bintray.com/baole/maven'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Nothing special here either.
What I've tried
I also tried to compare the project with another project I have, which doesn't have any issues with Proguard, but I can't find any special difference between them.
The question
Why doesn't Proguard get to work on the project when I sign the app? What should I do to make the special flags work too?