Is app-release.apk zipaligned apk? - android

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.

Related

How to disable proguard in release build in android

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 .

what happens when there's only one build type (release) in build.gradle

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.

Android Studio Preview 3 error when generating release APK : release-stripped.ap_ does not exist

I updated Android studio from Preview 2 to Preview 3 and now I get this error when I try to generate a release APK:
Error:A problem was found with the configuration of task ':app:packageProdRelease'.
> File '/Users/jay/repositories/test/app/build/intermediatesError:A problem was found with the configuration of task ':app:packageProdRelease'.
> File '/Users/jay/repositories/test/app/build/intermediates/res/resources-prod-release-stripped.ap_' specified for property 'resourceFile' does not exist.
I've read that it might be related to instant run feature so I disabled it and still the same error. And then, I tried to set shrinkResources attribute to false and then It works. BUT when I tried uploading the apk in Google Developper Console, it says my apk is not Zipaligned...
Wherever you are Google Developper, Help me out! :O
This problem occurs to me if I am using gradle 2.2.0-alpha3. I found a workaround to this problem. You can solve this by disabling shrinkResources and zipalign in gradle and then run zipalign using command line.
build.gradle:
shrinkResources false
zipAlignEnabled false
Run the zipalign command manually:
<your-android-sdk-path>/sdk/build-tools/23.0.3$
./zipalign -v 4 <your-input>.apk <your-output>.apk
Edit:
I just have a try on using older version of gradle 2.1.0, it works without this problem. zipalign problem in gradle 2.2.0-alpha3 is mentioned in this SO thread as well.
I was trying to use com.android.tools.build:gradle:2.2.3 in the project build.gradle file which was causing me issues.
I found that I was able to successfully generate a signed APK whenever I changed it to com.android.tools.build:gradle:2.1.0
According to a Google Engineer, enabling both minifyEnabled and shrinkResources should work:
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

\build\intermediates\res\resources-anzhi-debug-stripped.ap_' specified for property 'resourceFile' does not exist

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.

Can't release without runProguard false in Android Studio

I tried uploading my apk to Googleplay because of this.
You uploaded an APK that is not zip aligned. You will need to run a
zip align tool on your APK and upload it again.
So I added buildtypes for using zipalign with proguard in build.gradle
buildTypes {
release {
runProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
zipAlign true
}
}
but I got this error code during making signed apk file.
Generate signed APK: Errors while building apk, see messages tool
window for list of errors.
so I tried building signed apk with setting runProguard false, actually it worked.
but I really wondering why I couldn't make signed apk with Proguard.
Check the location and path to the key signature.

Categories

Resources