keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=***** // 替换成相应的密码
MYAPP_RELEASE_KEY_PASSWORD=***** // 替换成相应的密码
...
android {
...
defaultConfig { ... }
// 开始
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
// 结束
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
...
// 找到 def enableSeparateBuildPerCPUArchitecture = false
// 修改为 def enableSeparateBuildPerCPUArchitecture = true
// 找到 universalApk false
// 修改为 universalApk true
// 找到 def enableProguardInReleaseBuilds = false
// 修改为 def enableProguardInReleaseBuilds = true
// 最后清空缓存
// Android Studio Build > Clean Project
cd android && ./gradlew assembleRelease
// 包位置 android/app/build/outputs/apk/app-release.apk
cd android && ./gradlew installRelease
原文:http://blog.51cto.com/12173069/2096281