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
Related
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'
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'
}
}
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'
}
I'm new to Proguard configuration, so please correct me if I'm doing something wrong.
After playing with Gradle and Proguard configuration, I got two main options: either setting useProguard false or deleting that line.
First option:
buildTypes {
release {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Second option:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
The thing is that in the first case my APK-file size is 8 mb but it is not obfuscated and in the second case it becomes obfuscated but gets more than twice the size: 18 mb.
Proguard rule is the same in both cases:
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.ConscryptPlatform
So how do I make my APK both small and obfuscated?