As the title says.... I'm trying to understand any possible differences between the "debug" and "release" build variants of my Android app in addition to those specified in the build.gradle file.
The reason for asking is that I'm trying to pin down some odd things that are happening when I build my Android app as a release build rather than a debug one, and I'm wondering what may be happening behind the scenes that I don't know about.
Here's the current version of the buildTypes section of build.gradle:
buildTypes {
debug {
debuggable true
}
release {
debuggable true
signingConfig signingConfigs.config
// Disable Proguard altogether, hopefully:
minifyEnabled false
// getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Beside this lot, is there anything done automatically in the release build by Android Studio? I'm using Android Studio version 2.2.3.
ASIDE 1 - Before anyone says that I shouldn't have debuggable true in a release build, I know that - I'm just trying to make the two builds identical in every respect so that I can pin down the weird things that are happening.
ASIDE 2: I've already seen this question, and it doesn't address my one.
Thanks in advance!
Related
HI I have develop one app which is working perfectly in debug . but same code base when i trying to run code in release build some API is not firing because proguard . i dont know its because of proguard or minifyEnabled true or shrinkResources true then i made both false as below .
buildTypes {
release {
minifyEnabled false
shrinkResources false
crunchPngs false // Paste this line
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
using above code its working fine but when i try to upload build in play store release build with signed bundle file then its showing below error :
You uploaded a debuggable APK or Android App Bundle. For security reasons you need to disable debugging before it can be published in Google Play. Learn more about debuggable APKs and Android App Bundles.
please help me how to fix this issue .can we disable proguard for release build if not then how to fix this issue .
There is a large project for Intune portal with a lot of dependencies, and recently I found that the release build does not show up as a managed app, as if it does not use the Intune SDK.
I checked earlier versions of the project and they have the same problem.
intune portal "MAM enabled no"
The only thing that solves the problem is to set the debuggalbe flag to true, but it is not a solution. Obfuscation disabled and minifyEnabled set to false. I only change the single debuggable flag.
My buld.graddle(app) with issue:
buildTypes {
release {
debuggable false
minifyEnabled false
}
}
Without issue:
buildTypes {
release {
debuggable true
minifyEnabled false
}
}
intune portal "MAM enabled yes" on debuggable release apk
To localize the problem, I also checked the sample project with the Intune SDK and it is detected as a managed app regardless of the state of the debuggable flag.
So the problem has something to do with the build process of my project with the debuggable flag turned off. But I don't understand why the debuggable flag changes my apk at all, I took it to be just a token that appears in the final AndroidManifest.xml.
The Android Studio built-in apk analyzer shows significant differences between byte code with the debuggable flag set to true and false.
comparing apks with and without debuggable
comparing size of debuggable and nondebuggable release apk
The most important question I'm looking for an answer to is exactly how the byte code changes when debuggable true is set. And if you know how intune portal determines that apk MAM enabled.
Gradle 6.9
Android Gradle Plugin 4.2.2
Thank you in advance.
In build.gradle (app) file we have this by default,
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
According to https://developer.android.com/studio/build/shrink-code,
minifyEnabled true make the code more secure (making it hard to reverse engineer) and also shrink the size in release build, which we use for publishing the app.
I know that using minifyEnabled true makes compile time longer, but usually debug builds are used for development and testing, which is not affected anyways.
What I'm looking for is that, what are the disadvantages (such as performance impacts) cause by using minifyEnabled true at runtime. I'm not worried about the build time of a release build.
Google Play Console also recommending us to enable it therefore I'm wondering why is minifyEnabled is disabled by default.
By adding minifyEnabled true in your release build you can obfuscate code but it is set to false by default in release builds because if set true it shall require proguard rules to be written to tell the compiler which classes are to be ignored while obfuscating the code. If minifyEnabled is set to true by default and the developer forgets to add proguard rules, it can lead to runtime crashes.
However, setting minifyEnabled to true and shrinkResources to true can reduce your apk size.
As NIKHIL AGGARWAL said, setting minifyEnabled to true can lead to runtime crashes.
You should research each used library so that include their ProGuard rules into your project. Also sometimes after Gradle or libraries upgrade you should again check ProGuard rules and accordingly update them in your project.
You should add data classes of your network model to ProGuard.
You should check your release build on several devices/emulators with different Android versions to understand where it can crash. Debugging in release build is difficult and with obfuscation it becomes a nightmare.
However after you set minifyEnabled = true and avoid crashes you will decrease apk size and impede to cracking attempts.
my app's build.gradle has only the release build type inside the buildTypes section:
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Does this mean i don't have a debug buildtype ? or is debug implied someway ?
Does this mean i don't have a debug buildtype ?
No.
When a new module is created, Android Studio automatically creates the debug and release build types. Adding it to the build.gradle is necessary if you want to want to add or change certain settings.
Based on the documentation:
The debug build type doesn't appear in the build configuration file,
Android Studio configures it with debuggable true. This allows you to
debug the app on secure Android devices and configures APK signing
with a generic debug keystore.
You can add the debug build type to your configuration if you want to
add or change certain settings.
In my debug android app I made a sign in into firebase with google and facebook and it worked well, but after generating signed APK it's not working, I updated SHA1 in firebase project with release SHA and updated key hash in facebook for developers also but it still not working what can I do.
Most of the times things like this happens because of proguard, it removes some of the files when building apk. Check if it works when proguard is disabled. if it works then try to configure proguard to keep all required files.
To disable proguard set minifyEnabled false in build.gradle
after changing it will look somewhat like
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
To further configure proguard you can easily find tutorial on google.
Some helpful links:-
https://stackoverflow.com/a/26274623/5176343
https://stackoverflow.com/a/15761408/5176343
It's tough to say without seeing the code, but one thing that has worked for me in the past was turning off proguard and/or minify in build.gradle. Those things were changing property names in the release apk for me which then caused de-serialization to fail for me because the names didn't match what was in the json.
Have you selected a build version to release and than generate singed apk i hope this will work for you.