The debugger does not stop on any breakpoints. I tried clearing all breakpoints and adding them back in but I am seeing debug statements in the console.
According to this answer, Inside build.gradle for your app module, disable minifyEnable for my build variant and change it to false.
debug {
debuggable true
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
I did it also but also but still same problem.
Since you're in debug configuration you don't need to shrink resources or add proguard
debug {
debuggable true
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
change to
debug {
debuggable true
minifyEnabled false
// shrinkResources true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Related
I want to obfuscate my android code, I have set minifienable true and setup proguard file, but after generating apk and decompile, the code is not obfuscated. This is my proguard :
my proguard file:
-dontwarn com.huawei.**
-dontwarn org.conscrypt.*
-dontwarn org.openjsse.javax.net.ssl.*
-dontwarn org.openjsse.net.ssl.OpenJSSE
my build.gradle file
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug{
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
To enable ProGuard in Android Studio. Below is the sample how to enable default ProGuard in Android Studio.
Go to the build.gradle file of app
enable the proguard minifyEnabled true and useProguard true
enable shrinkResources true to reduce the APK size by shrinking resources.
proguardFiles getDefaultProguardFile('proguard-android.txt') to enable the default one. If you want to use your own proguard file then use the below rules.
release
{
debuggable false
useProguard true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
delete build file
invalidate cache and restart android studio
I'm using Android Hilt ViewModel. It's working fine for debug mode below:
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
but when I change to release mode, Android Hilt not working. Especially when I change shrinkResources to true or debuggable to false, It's will not working. Below is my release mode:
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
Below is my proguard:
-dontwarn com.google.errorprone.annotations.**
-keepnames #dagger.hilt.android.lifecycle.HiltViewModel class * extends androidx.lifecycle.ViewModel
Please help me!
I am trying to take singed apk build but generating the build getting too much of time (nearly 30 min)
build.gradle:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Set to false these line if you are not using proguard rule file
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
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.
The debug APK we generated is 30 MB, while on the other hand, the release APK is 40 MB
Both uses the same proguard and gradle config, as below :
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig getSigningConfig()
}
debug {
debuggable true
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig getSigningConfig()
}
}
Please leave a comment if you need more code to analyze this problem
Thanks