I am trying to export signed apk, obfuscated with proguard. But after process, I can see my code and my class names in decompiler tool. Spent 1 day , but can't understand what I missed.
In my gradle file I specified :
buildTypes {
release {
apply plugin: 'maven'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
proguard-rules.pro is empty.
Should I specify anything else to enable proguarding ? After decompilation
Change minifyEnabled to true to enable proguard in your build configuration.
Related
So iv'e been enabling Pro-Guard to a project and after building the apk i decompiled it to make sure Pro-Guard did he's job and notices that it adds, for example, to the BaseAdapter class -
/* compiled from: BaseAdapter */
See picture -
Now I'm asking, doesn't it lose the point of the Pro-Guard if it says what class that was?
Is there any way to tell the Pro-Guard not to add this info line at all the classes?
My code where i added Pro-Guard -
buildTypes {
debug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
shrinkResources true
}
release {
signingConfig signingConfigs.somethingsomething
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
shrinkResources true
}
}
Thanks.
Proguard is not adding this line.
/* compiled from: BaseAdapter */
The decompiler is doing mapping of obfuscated name with original name. You are seeing it as you might be using jadx or online service like this
You can try using dex2jar and jd-gui to look at decompiled code. This line will not be present there.
Make sure that 'proguard-rules.pro' file does not have following attributes in it.
-keepattributes SourceFile
If you add this statement no decompiler will be able make this mapping.
So it looks like there is a bug in the latest play-services to be deployed.
Does anyone know how to work around this issue?
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myappname:transformClassesWithAndroidGradleClassShrinkerForDevelopmentDebug'.
> ProGuard configuration parser error: /Users/myusername/.gradle/caches/transforms-1/files-1.1/play-services-base-11.8.0.aar/d2ad9e16677fda9cf07a1280a66e91ca/proguard.txt line 3:88 no viable alternative at input '<fields>'
So more information. seems the problem is in the core module:
Error:Execution failed for task ':myappname:transformClassesWithAndroidGradleClassShrinkerForDevelopmentDebug'.
> ProGuard configuration parser error: /Users/myusername/.gradle/caches/transforms-1/files-1.1/play-services-base-11.8.0.aar/d2ad9e16677fda9cf07a1280a66e91ca/proguard.txt line 3:88 no viable alternative at input '<fields>'
EDIT:
The contents of the file that is causing that error is:
# b/35135904 Ensure that proguard will not strip the mResultGuardian.
-keepclassmembers class com.google.android.gms.common.api.internal.BasePendingResult {
com.google.android.gms.common.api.internal.BasePendingResult.ReleasableResultGuardian <fields>;
}
It seems the default shrinker has changed. Adding the configuration to turn on ProGuard seemed to work.
buildTypes {
release {
debuggable false
minifyEnabled true
useProguard true
...
}
debug {
debuggable true
minifyEnabled true
useProguard true
...
}
}
In addition to the above solution (which works): the issue seems related to Instant Run as well.
If you disable Instant Run, you can build your app without changing your build.gradle.
Probably, the default shrinker has changed only when building for Instant Run.
This solution helped me:
First, in app/build.gradle change useProguard to 'true'
Second, in proguard rules add line '-dontobfuscate'
buildTypes {
release {
debuggable false
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
...
}
debug {
debuggable true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
...
}
}
proguard-rules.pro
-dontobfuscate
So, minify would be work, but code wouldn't obfuscate.
I am noticing that if you disable Instant Run the build still fails with the same error (if you have minify enabled but Proguard disabled to shrink your code to avoid multi-dex in the debug build). If you follow Brill Pappin answer you must enable Instant Run(and install libraries as prompted) to hit any breakpoints while debugging.
It seems enabling the shrinker as described in the Google docs now only works if you are using Instant Run with the Google Play Play Services.
I have enable proguard, but for tracking bugs I need a mapping file to upload to Google Play.
Here is my gradle configuration of proguard:
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
try to find the mapping file at build/outputs/proguard/release/mapping.txt in your application module's directory.
if you have -dontobfuscate in your proguard. please remove it
rebuild and rerun.. Then it should able to see the mapping file in proguard directory
I'm trying to configure proguard to use it with my espresso UI test flavor. The thing is Proguard tends to ignore my debug proguard config.
This is how the config looks:
buildTypes {
debug {
minifyEnabled true
proguardFiles 'proguard-debug.pro'
testProguardFile 'proguard-debug.pro'
signingConfig signingConfigs.release
}
}
I added testProguardFile but it doesn't seem to work on androidTest. I'm running mockDebug flavor variant. When I just run the app it works fine, but when I try to run test which is located in adnroidTest it won't run due to proguard warnings, like the proguard file wasn't processed at all and the file is pretty straight forward:
proguard-debug.pro
-dontobfuscate
-dontoptimize
-dontwarn
Before someone starts to advise me turning off proguard for debug builds: I need to have it enabled because of multidex.
If you want your test build as close as possible from the real deal, try this one:
# build.gradle
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFile 'proguard-test.pro'
}
and
# proguard-test.pro:
-include proguard-rules.pro
-keepattributes SourceFile,LineNumberTable
On other hand, if you need it only because multidex, if your are using minSdkVersion < 21, ProGuard is tied to multidex flag and run automatically.
You also need to add the default proguard rules:
proguardFiles getDefaultProguardFile('proguard-android.txt')
This line can be removed, as it is a duplicate:
testProguardFile 'proguard-debug.pro'
I am using lasted version of Android Studio, and i have obfuscated my project by ProGuard in Android Studio.
edit content of Build.gradlesuch as this :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
but when start the build project, an error like that
warning Image :
How can I fix this?
Simply add -dontwarn com.github.siyamed.shapeimageview to your proguard-rules.pro.
I had same issue,try to change minifyEnabled true to minifyEnabled false.
And just refer this enter link description here