Build android bundle along with apk with one command - android

If using Android Gradle Plugin version 3.4.2 or prior the command ./gradlew bundleRelease will generate both bundle and apk of the app. But after upgrading to 3.5 version it generates only the bundle.
Is it possible to get the former behaviour, by means of some configuration or adding some parameters to the command?
It was convenient to have both apk and bundle with one command earlier (the bundle is being uploaded to Google Play, whereas the apk is being uploaded to the Beta by Crashlytics). Now I need to add another step ./gradlew assembleRelease and it takes longer to execute them both.

Finally after some hit and trials, I found that we can run multiple actions in one line command.
Like here I am doing a clean first and then creating a bundle and an apk -
gradlew clean bundleFlavorBuildType assembleFlavorBuildType
where Flavor is flavor name and BuildType is release/debug/custom buildType. If you want to build both release and debug apk & aab. e.g. flavor is chocolate
gradlew clean bundleChocolate assembleChocolate
This will output chocolate-relase & chocolate-debug aab, apk both.

Related

How to create aab instead of apk from Jenkins

I want to configure my personal app to be built as an android app bundle rather than apk in Jenkins. How do I configure my Jenkins to build aab and not apk
You need BundleTool You can use bundletool to create an aab and sign it and even test it.
You can install Bundletool just like another CLI utility and execute commands in Jenkins.
Or you can just execute a Gradle task like bundleRelease to generate your release aab.
Here is much detailed on how to do so.
https://developer.android.com/studio/build/building-cmdline#bundletool-build
https://developer.android.com/studio/command-line/bundletool

How to get the updated Apk file from the android studio.?

I am developing an android application. All the things is going well when I run the application into genymotion virtual device.And Since the apk is stored in F:...\app\build\outputs\apk location. So I just want to collect it from this location and download it to install in a android phone.As I simultaneously updating the application with code but this apk doesn't provide me the updated apk file according to the updated code .They just give me the old apk file even if i run my application again and again from the android studio. Can anyone suggest me why this is happening ??? I just want to run this apk into phone or download this apk file for another purpose.
This three steps will do Go build->Build apk
Go to Build > Build APK to generate a normal APK.
Go to Build > Generate Signed APK to generate signed APK.
Signed APK are those which we generate to release our application. Here it is, why is it necessary to generate signed APKs: Why should I Sign my Application APK before release
If you build a debug APK, it will still work on all devices but you cannot release it.
From terminal run the following command to make sure that you get the updated apk.
1. gradle clean (from windows )
-or-
./gradlew clean (from linux) -
Above command deletes the build folder.
2. gradle build (from windows)
-or-
./gradlew build(from linux)
Above command builds all the flavor for your application.
Edit: Original answer
Signed apk is needed to install in any other non debug device. This will be same as the debug app that runs in your test device/emulator.
Build -> Generate signed apk

Updating apk SHA1 differs even after using same keystore

I have uploaded my app to Goggle Play few months back after signing it with a release keystore, I have stored that Keystore for future updation. Now I have updated the apk with some changes, while trying to upload the new apk signed with same keystore along with same alias and password, the apk is not allowed to upload to Goggle Play.
Playstore shows me following error :
The only change is, earlier the appication was developed and build using eclipse and now in android studio Can this be the reason for showing the above error???
From the error message I would say you have mixed up the keystores, or android studio is just using the wrong one to do the release build. The best way to be completely sure is to clearly setup your build.gradle, and build it yourself on the command line using
./gradlew clean assembleRelease
What is probably happening is that Android Studio is using your debug keystore (ie. the default) to sign the release build because it can't find the original keystore you used in eclipse, or you have the wrong password somewhere...
Have a look at this configuration, note the location of the keystores, the naming convention and how it corresponds to the build.gradle. Note the signingconfigs and how they are setup for the release build. To build from the command line, simply cd into the directory with your "gradlew" file, and run
./gradlew clean assembleRelease
to build the release apk, or
./gradlew clean assembleDebug
to build the debug apk. If it fails, try
./gradlew clean assembleRelease --stacktrace
Screenshot of build.gradle and filesystem setup
But please remember not to put your keys in your source control! That means editing your .gitignore file.
There is a stack of information on how to do this here:
http://developer.android.com/tools/publishing/app-signing.html

How can I deploy a release signed apk to attached device using gradle?

I have a keystore file with two keys: one for debug build and another for release build type. So my gradle build script generates two apks on need. Now, to deploy the debug build apk android gradle plugin has installDebug task in it but how about deploying the release build apk? Andorid gradle plugin doesn't have any task like installRelease. How can I deploy the release build apk directly to the connected devices using gradle?
The Android Gradle Plugin already includes the installRelease task but if you don't see it probably there is a signing configuration problem.
From the documentation:
Finally, the plugin creates install/uninstall tasks for all build
types (debug, release, test), as long as they can be installed (which
requires signing).
You can try to figure out what's wrong with the signingReport task:
./gradlew signingReport

Release version of *.apk in Android Studio

I want to submite an application to Google Market. I found there is only one apk file generated in a project, its path is Project1Project/Project1/build/apk/Project1-debug-unaligned.apk
It looks like it's a debug version. Where do I find (if any) a release version of an application or how do I generate it?
Since Android Studio is based on IntelliJ, that's how to do it in IntelliJ:
Build -> Generate Signed APK
and provide it with your key and its password.
You can build an unsigned release version. See the answer here. I don't see an easy way to do it from the GUI, but you can use the shell command:
./gradlew assembleRelease
Make sure to cd to your project's directory before running the command. This will produce the file
Project1Project/Project1/build/apk/Project1-release-unaligned.apk
If you run ./gradlew assemble, both the release and debug version will be built.
More documentation here.
From Android Studio 1.3.1, the ready-to-publish apk location is :
app -> app-release.apk
This should be published to Google Play
Intermediate apks are at :
app -> build -> outputs -> apk -> app-release-unaligned.apk
This is Intermediate result of Signing process, should not be published to Google Play
Android gradle produces apk in two binaries: Unaligned and Aligned. Unaligned refers to how the data, files are structured within the APK file. A utility called zipalign modifies the APK to align data in a way that is optimized for users. Unaligned simply skips the zipalign stage.
Whereas an Aligned APK is an optimized version. The files are more structured and compressed, which helps the app run faster. They are also optimized for RAM usage so they can consume less RAM on the devices.
you will also see size difference in the APK generated.

Categories

Resources