I have an app that works fine in debug mode, but when I create a signed apk and install it on the same phone, some features do not work.
Is there a way to get console messages from the release version?
Thanks in advance.
#Matt If it is working fine in your simulator while running in debug mode then obviously it should work with your apk in mobile device as well. Actually elaborate your question.
In you release gradle build change to this
release {
multiDexEnabled true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
multiDexEnabled true
minifyEnabled false
shrinkResources false
}
hope this is helpful .
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 .
I would like to publish a a library with debuggable true on release build types. This would help me debug that library. What are the potential problems if this library goes into production? Is it secure ? What difference does it make when released with debuggable as false?
buildTypes {
release {
minifyEnabled true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
First of all, you can not publish an apk with debuggable set to true.
Google play console will give you an error just after you upload the apk.
Secondly, it is not secure at all. Your apk will be very slow.
There are differences in a debug build and a release build. Release builds are much faster. Release builds do not print logs (it is a good practice to not print logs in release builds) which makes execution slower as it takes time to print the characters in the console and all print commands are usually in sync.
Moreover, a release build may also trigger code obfuscation and splits.
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.
I updated Android Studio to version 2.0. The build failed and also takes longer than Android Studio version 1.5 to build. Every time I run my application, I clean and reload the project, but it's no use. The error message is:
\build\intermediates\res\resources-anzhi-debug-stripped.ap_' specified
for property 'resourceFile' does not exist.
Having same issue !
So instant run is not compatible with shrinkResources
1) if use Android Studio 2.2
shrinkResources false
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
zipAlignEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
2) if use Android Studio 2.0
open setting
now run your project
If you're experiencing this issue when building a release build, keep in mind that Android Plugin for Gradle 2.2.0 (and above) seems to have a bug with shrinkResources.
Downgrade gradle to 2.1.3 for a temporary solution:
classpath 'com.android.tools.build:gradle:2.1.3'
EDIT:
I reported this issue to wojtek.kalicinski (Android Developer Advocate at Google).
As it turns out, shrinkResources works only if there is minifyEnabled set to true. 2.1.3 version of Android Plugin was just ignoring the issue (and failing to shrinkResources silently). 2.2.0+ is letting you know that there is something wrong with an error (which itself isn't really informative). Google might introduce a better error message for this kind of scenarios in the future.
Here's the twitter conversation:
Probably you are shrinking the resources while avoiding minifying:
minifyEnabled false
shrinkResources true
If you want to shrink the resources, you have to enable minifying:
minifyEnabled true
shrinkResources true
Older versions of Build Tools were ignoring this issue, but it started throwing compilation issues on Build Tools 2.2.3
More information here: https://developer.android.com/studio/build/shrink-code.html#shrink-resources
Set shrinkResources to false. It worked for me
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
jniDebuggable false
zipAlignEnabled true
}
}
Found an answer, just disable instarun and it should work. It worked for me.
We could use both Instant Run and shrinkResources at the same time;
Please be noted that we CANNOT use Jack and shrinkResources at the same time (the same to ProGuard, minifyEnabled)
As suggested by #Bartek-lipinski's post, I have confirmed on my own project that downgrading Gradle plugin to v2.1.3 will solve this problem of getting "InvalidUserDataException: File specified for property does not exist."
I have filed a bug with the Android tools bugtracker website, please upvote to get some more visibility on the problem.
In my project, because I added in the gradle shrinkResources, remove the Ok.
I am using Android Studio 1.0.2.
When I click assembleRelease in gradle tasks, two files are generated, app-release-unaligned.apk and app-release.apk. I know app-release-unaligned.apk is unaligned but what is app-release.apk? Is it aligned apk? My build.gradle is like below.
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
signingConfig signingConfigs.config
zipAlignEnabled true // Is this necessary or not in Android Studio 1.0.2?
}
}
Even if I didn't put zipAlignEnabled true, app-release.apk is generated.
Is it still necessary in Android Studio 1.0.2?
All information I get about zipalign is before Android Studio 1.0 comes out.
You don't need to set that flag.
From official guide
The possible properties and their default values are:
It is both aligned and signed.
Ready for publication.
AFAIK zipAlignEnabled is true by default for release builds.