Skip to content

Instantly share code, notes, and snippets.

@richjava
Last active December 2, 2020 01:43
Show Gist options
  • Save richjava/1dfa3e4069acb4928f37 to your computer and use it in GitHub Desktop.
Save richjava/1dfa3e4069acb4928f37 to your computer and use it in GitHub Desktop.
Gradle assembleRelease in Android Studio
For setup of Gradle:
1. Set gradle home in env variables, i.e. GRADLE_HOME C:\gradle-[version-number-goes-here]
2. Put Gradle bin in PATH env variable (append it to the end with';' before it): i.e. ;C:\gradle-1.12\bin
3. Add Android SDK to System Variables.
For release:
1. In module's build.gradle file have something like this (use minifyEnabled instead of runProguard in gradle version 1.0.0+, see http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0):
// for release
signingConfigs {
release {
storeFile file('release.jks')
storePassword System.console().readLine("\nKeystore password: ")
keyAlias "MyAlias"
keyPassword System.console().readLine("\nKey password: ")
}
}
buildTypes {
release {
signingConfig signingConfigs.release
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
zipAlign true
}
}
//end for release
//for dev
// buildTypes {
// release {
// runProguard false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
// }
// }
2. Generate release.jks file using Build > Generate Signed APK (Android Studio)
3. Put release.jks in module file (i.e. app) - not the project file
4. When Gradle is installed on computer, in Command Prompt, navigate to project (not module) and run gradlew assembleRelease
5. Go to [module]/build/apk (or [module]\build\outputs\apk) and upload app-release.apk to Google Play.
For more info on the Android Build System, see: http://developer.android.com/sdk/installing/studio-build.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment