How to create a release signed apk file using Gradle?

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

    android {
        compileSdkVersion 17
        buildToolsVersion "19.0.3"
    
        defaultConfig {
            minSdkVersion 9
            targetSdkVersion 18
        }
    
        File signFile = rootProject.file('sign/keystore.properties')
        if (signFile.exists()) {
            Properties properties = new Properties()
            properties.load(new FileInputStream(signFile))
            signingConfigs {
                release {
                    storeFile rootProject.file(properties['keystore'])
                    storePassword properties['storePassword']
                    keyAlias properties['keyAlias']
                    keyPassword properties['keyPassword']
                }
            }
        }
    
        buildTypes {
            release {
                runProguard true
                zipAlign true
                proguardFile rootProject.file('proguard-rules.cfg')
                signingConfig signingConfigs.release
            }
            debug {
                runProguard false
                zipAlign true
            }
        }
    }
    

提交回复
热议问题