问题
I want to build apk from command line with the help of gradle. Which command should I use to build apks for only release flavours?
回答1:
Debug
./gradlew
Release
./gradlew assembleRelease
your gradle file should contains:
android {
[...]
signingConfigs {
release {
storeFile file("../keystore.jks")
storePassword "pwd"
keyAlias "alias"
keyPassword "pwd"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
[...]
}
回答2:
You can run these commands:
assemble - Assembles all variants of all applications and secondary packages.
build - Assembles and tests this project.
If you want a specific flavor or buildtype use:
assembleDebug - Assembles all Debug builds.
assembleRelease - Assembles all Release builds.
In your case use:
./gradlew assembleRelease
来源:https://stackoverflow.com/questions/40219917/what-is-the-difference-between-gradlew-build-and-gradlew-assemblerelease