Why proGuard doesn't work when its active? - android

I want to reduce my app size.
I saw some tutorials and understood that I have to use the following code in build.gradle(app) :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
I tried it but the app size didn't change until I added another code and it worked :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
My question is why it should be use debug because it wasn't used in tutorials I saw.
I'm worried about slow app with this way.
Note : My Android Studio version is 3.5 and my gradle version is 7.0.4.

An Android Studio project default buildtype is debug, you can see it on "Build Variants" panel on left bottom corner of Android Studio. You can also change it to release

Related

Unable to Obfuscate the Android library .aar file using Ionic 6/Cordova

I have created the .aar(Android library) for ionic 6/cordova project. But unable to obfuscate the java class files, i.e, able to see the content of the file. Below is the configuration used in app level build.gradle.
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
debuggable false
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
It would be great if some one help on this?

Android version release warning message: This App Bundle contains Java/Kotlin code, which might be obfuscated

I got this warning message:
This App Bundle contains Java/Kotlin code, which might be obfuscated. We recommend you upload a deobfuscation file to make your crashes and ANRs easier to analyze and debug
what does it mean? what is the shortest solution for this?
Seems like it's a warning message coming from the new play console, you can solve it just by setting your minimum api level to 29 or even better by uploading the retrace mapping file as described here.
Enable minify :
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
After building apk/app bundle you can find /app/build/outputs/mapping/release/mapping.txt file . New console will allow you to upload mapping.txt along with your apk or bundle. You can find this option from App bundles and APKs menus.(According to this)
Just changing minifyEnabled to true worked for me
You can solve this by just enabling minify in your build. gradle(app) file:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Just enable minify in your build.gradle(app) file:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
proguard-android-optimize.txt sometimes is unsupported so using the following is safer (see this):
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

Generating signed apk stucks when minifyEnabled true is used

While generating releases apk with minify enabled true ,gradle build doesn't finish and stucks at app:crashlyticsUploadDeobsRelease.
gradle build log
Replace your build Types code with this code in app level gradle file. when you are debugging or running code on your device before final release then select built variant debug and when you are going to built signed apk for release then select built variant release
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

gradle minifyEnabled false in buildTypes debug issue

This question might seem like a "duplicate question" but I've been looking at the same issue in S.O. and Google and I haven't found anything so before downvoting please read the question closely.
Inside my buildTypes (build.gradle) I want to enable proguard only for release mode, so I set inside debug block minifyEnabled false but if I put a breakpoint in debug mode it's skipped, otherwise if I set minifyEnabled false also inside release block all works fine.
Just tried clean, rebuild, invalidate cache. Nothing seem to works.
This is my buildTypes block:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Has someone encountered the same problem?
Thank you very much for your time and assistance in this matter.
Flag minifyEnabled stays for ProGuard, and it's turned off by default. So, in default setup both debug and release builds aren't using ProGuard, and parameter proguardFiles is effectively ignored

Android proguarded apk still readable

I tried to proguard my app. It successfully obfuscated the apk. However, when i try to view the java code of my apk using Apk_oneclick, I am able to. I have created a release version of my apk. Still the problem persist. Any help would be much appreciated.
Thanks in advance.
build.gradle:
Proguard Rules:
Java code from the release-apk:
For enabling ProGuard configurations for your application you need to enable it in your module level gradle file. you need to set the value of minifyEnabled true.
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
You can also enable shrinkResources true which will remove resources that ProGuard flaggs as unused.
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
You need to set following property
and add some rules in proguard-android
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Got it working. Cleaned the project and ran the same with some changes in the Proguard rules.

Categories

Resources