How to create a release signed apk file using Gradle?

前端 未结 30 1812
既然无缘
既然无缘 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:13

    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

提交回复
热议问题