Android Studio: how to generate signed APK using Gradle?
There are three ways to generate your build as per the buildType
. (In your case, it's release but it can be named anything you want.)
Go to Gradle Task in right panel of Android Studio and search for
assembleRelease
orassemble(#your_defined_buildtype)
under Module TasksGo to Build Variant in Left Panel and select the build from drop down
Go to project root directory in File Explore and open cmd/terminal and run:
Linux:
./gradlew assembleRelease or assemble(#your_defined_buildtype)
Windows:
gradlew assembleRelease or assemble(#your_defined_buildtype)
If you want to do a release build (only), you can use Build > Generate Signed apk. For other build types, only the above three options are available.
You can find the generated APK in your module/build
directory having the build type name in it.
How to create a release signed apk file using Gradle?
Easier way than previous answers:
Put this into ~/.gradle/gradle.properties
RELEASE_STORE_FILE={path to your keystore}
RELEASE_STORE_PASSWORD=*****
RELEASE_KEY_ALIAS=*****
RELEASE_KEY_PASSWORD=*****
Modify your app/build.gradle
, and add this inside the android {
code block:
...
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
// Optional, specify signing versions used
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
....
Then you can run gradle assembleRelease
Also see the reference for the signingConfigs
Gradle DSL
Android studio - Generate signed APKs broke
After a few days of struggle, I ended up switching to Bundle. It achieves the same purpose for me and it actually works so... That's my solution here.
Gradle error when generating signed APK in Android Studio
If you are not actively linting a project, it might be easier just to disable it.
android {
...
lintOptions {
checkReleaseBuilds false
}
}
That code should prevent that particular gradle task for running.
Generate Signed APK in Android Studio
In left bottom corner of Android Studio, select the Build Variances, then you can change the build mode to "release". When building in release mode, I think the "Generate Signed APK" wizard works. So just ignore the build.gradle configuration!
Related Topics
Nexus 5X Reverse Landscape Sensor Fix in a Android Camera Preview App
Disable Home Button in Android Ics (4.0)
How to Break Styled Text into Pages in Android
Android Raw Folders - Creation and Reference
Failure [Install_Failed_Older_Sdk] Android-L
Should Use "Sp" Instead of "Dp" for Text Sizes
How to Detect Android CPU Speed
Broadcast Receiver Not Working in Android Oreo
Can Not Set Debuggable Flag in Androidmanifest.Xml
How to Show Text in Android System Status Bar
Android - Build Separate APKs for Different Processor Architectures
How to Use Asynctask to Display a Progress Bar That Counts Down
Gradle Duplicate Entry: Java.Util.Zip.Zipexception
Want to Compile Native Android Binary I Can Run in Terminal on the Phone