Obfuscation (minifyenabled True) Not Working In Debug And Release
Solution 1:
Well... As you haven't mentioned yet, to the ant, to pro-guard your app, That's why it is not able to obfuscate it. Use explicitly
useProguard true
Need a simple example of app gradle build file...? Find it below as it is of my project :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.xxxxxxxxxxcccccccvvvvvv.apps.firebase"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
}
}
}
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'
}
Now what it means in wording : It will only
obfuscate
your code in release of your project; which means you have to build your release apk.
How to test...? obfuscation happened or not?
Here we go...
- Unzip apk file from linux or mac os terminal as: unzip apk_name
- You will get your project files extracted... find dex file
- Use dex2jar to convert it into jar
- Read that jar file with JD-UI app
- You will see all your java classes and core code files
- Yes.... look neat.... Its a code.... But with obfuscation
Hmmmm... Hope it helps
Edit : 2
In the pro-guard rules files... Do not try to program it like code, just keep some classes which are not so important as : -keep public class OpenSource
Thats it.
Edit : 3
Most importantly you should and must as a beginner use default pro-guard file set by android studio or whichever your IDE; while creating the project. like :
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Edit : 4
It is a good habit to create a new sample project, learn how to implement any concept, once we are hands on it and cleared the concept..., Open the main project and implement it within..., As ... As of now , we are mastered the concept.
Edit : 5
It is always recommended to use Android Studio than any other IDE as it is officially by google as android is.. And it must be latest and updated IDE with minimum api 26 enabled. as google made compulsory last week that to upload apps on google play apps must target api level 26.
Also it helps to your project to get it build error free as all the latest dependencies are there along with patches.
Solution 2:
Try to delete the
.idea
and.gradle
directory under your project root directory and restart your Android Studio and re-sync your project. And change yourbuild.gradle
settings as below:android { ... compileSdkVersion 24 buildToolsVersion "24.0.0" defaultConfig { ... targetSdkVersion 24 ... } ... }
Double check all the libraries inside
libs
to see if you have any duplicate ones withcompile xxx
, because you have below library dependencies declaration.compilefileTree(include: ['*.jar'], dir: 'libs')
This may cause the duplicate inclusion of libraries, for example,
compile files('libs/gson-2.6.2.jar')
. Try to remove all the duplicate libraries.
Solution 3:
ever considered upgrading from Android Studio 1.5.1
to 3.1.3
??
and I've double-checked, that this is not a question from a few years ago.
it reads bad descriptor: charOffset
, which hints for errors in the build.gradle
... most likely, that the referenced proguard-android-optimize.txt
does not even exist within the file-system.
you'd have to reference the ProGuard configuration rules alike:
proguardFile "${project.rootDir}/proguard-rules.pro"
// proguardFile "${project.rootDir}/some-more-rules.pro"
shrinkResources true
minifyEnabled true
Post a Comment for "Obfuscation (minifyenabled True) Not Working In Debug And Release"