How to create a release signed apk file using Gradle?

前端 未结 30 1660
既然无缘
既然无缘 2020-11-22 13:48

I would like to have my Gradle build to create a release signed apk file using Gradle.

I\'m not sure if the code is correct or if I\'m missing a parameter when doing

30条回答
  •  青春惊慌失措
    2020-11-22 14:21

    In newer Android Studio, there is a GUI way which is very easy and it populates Gradle file as well.

    1. File -> Project Structure

    2. Module -> Choose the main module ('app' or other custom name)

    3. Signing tab -> Plus image to add new configuration

    4. Fill data on the right side

    5. OK and Gradle file is automatically created

    6. You will manually have to add a line signingConfig signingConfigs.NameOfYourConfig inside builtTypes{release{}}

    Images:

    enter image description here

    enter image description here

    Two important(!) notes:

    (EDIT 12/15)

    1. To create signed APK, you'd have to open Terminal tab of Android Studio (the bottom of the main interface) and issue a command ./gradlew assembleRelease

    2. If you forgot keyAlias (what happens often to me), you will have to initiate Build -> Generate Signed APK to start the process and see the name of the Alias key.

提交回复
热议问题