Reputation: 1352
Using Latest Android Studio and having updated all platform ( OsX) :
Build.gradle :
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.xxxxxxlxxxxxx.apps.firebase"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Proguard-rules.pro :
-keep public class OpenSource
As you can see proguard is enabled and rules also given for just keeping OpenSource
class. Still when i build its apk / signed apk. And uses following commands on apk file :
It would be very nice to have your suggestions on it. Thanks.
Upvotes: 4
Views: 9741
Reputation: 31
In case you think you are doing everything right (default proguard-rules, minifyEnabled = true, etc.) and yet classes and methods are not being obfuscated, please check that the build variant you are trying to obfuscate is NOT DEBUGGABLE (apparently debuggable builds are not obfuscated properly)
Upvotes: 0
Reputation: 24128
Newer gradle plugin versions don't use proguard. It uses R8 compiler instead.
When you build you project using Android Gradle plugin 3.4.0 or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the R8 compiler to handle the following compile-time tasks:
https://developer.android.com/studio/build/shrink-code
If you want to use proguard (in release build), add below to gradle.properties
android.enableR8=false
and use following in build.gradle.
buildTypes {
release {
debuggable false
useProguard true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Upvotes: 0
Reputation: 3673
To enable ProGuard in Android Studio. Below is the sample how to enable default ProGuard in Android Studio.
1) Go to the build.gradle
file of app
2) enable the proguard minifyEnabled true
and useProguard true
3) enable shrinkResources true
to reduce the APK size by shrinking resources.
4) proguardFiles getDefaultProguardFile('proguard-android.txt')
to enable the default one. If you want to use your own proguard file then use the below rules.
buildTypes {
release {
debuggable false
useProguard true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
useProguard true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Upvotes: 12