我想在gradle的帮助下从命令行构建apk。我应该使用哪个命令来构建仅用于发布版本的apks?
答案 0 :(得分:11)
调试
./gradlew
推出
./gradlew assembleRelease
您的gradle文件应包含:
android {
[...]
signingConfigs {
release {
storeFile file("../keystore.jks")
storePassword "pwd"
keyAlias "alias"
keyPassword "pwd"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
[...]
}
答案 1 :(得分:8)
您可以运行以下命令:
assemble - Assembles all variants of all applications and secondary packages.
build - Assembles and tests this project.
如果您想使用特定的flavor或buildtype:
assembleDebug - Assembles all Debug builds.
assembleRelease - Assembles all Release builds.
在您的情况下使用:
./gradlew assembleRelease