[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4 Generating the Application Package (APK)

Version Control If you will be generating a signed APK for publishing, and you are using Gradle version 8.3 or higher, commit all of the source code prior to generating the APK. The Android Gradle plugin includes the commit hash in ‘META-INF/version-control-info.textproto’.

In Android Studio, click on the Build menu then “Build APK”. If there were no errors, this should produce ‘app/app-release.apk’ (in Android Studio 2.3) or ‘app/release/app-release.apk’ (in Android Studio 2024). You should rename this file to a more descriptive name like ‘todo-1.3.0.apk’.

Alternatively from the command line, run the following commands:

./gradlew assembleRelease

This will produce an unsigned APK in ‘app/build/outputs/apk/release/app-release-unsigned.apk’. To sign this, you will need to locate the build tools for the version specified in ‘app/build.gradle’ under android.buildToolsVersion (if present; otherwise the most recent build tools supported by the Android Gradle plugin). You will also need to know where the keystore of your app signing key is located.

${BUILD_TOOLS_VERSION_DIRECTORY}/apksigner sign \
  --alignment-preserved \
  --ks ${ANDROID_KEYSTORE} --ks-key-alias ${SIGNING_KEY_ALIAS} \
  --out app/${APP_NAME}-${VERSION}.apk \
  app/build/outputs/apk/release/app-release-unsigned.apk

(The --alignment-preserved option is needed if you are using build tools 35 or higher. Omit it for earlier version of the build tools.)


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on March 30, 2025 using texi2html 5.0.