How to create a release signed apk file using Gradle?

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

    This is a reply to user672009 and addition to sdqali's post (his code will crash on building debug version by IDE's "Run" button):

    You can use the following code:

    final Console console = System.console();
    if (console != null) {
    
        // Building from console 
        signingConfigs {
            release {
                storeFile file(console.readLine("Enter keystore path: "))
                storePassword console.readLine("Enter keystore password: ")
                keyAlias console.readLine("Enter alias key: ")
                keyPassword console.readLine("Enter key password: ")
            }
        }
    
    } else {
    
        // Building from IDE's "Run" button
        signingConfigs {
            release {
    
            }
        }
    
    }
    

提交回复
热议问题