口味😋: 不同口味使用各自的Android密钥库文件进行打包签名
This commit is contained in:
parent
44686a1ba2
commit
c881790eb5
@ -2,15 +2,36 @@
|
||||
|
||||
A new Flutter project.
|
||||
|
||||
## Getting Started
|
||||
## 配置签名
|
||||
为发布渠道创建JAVA密钥储存(密钥库)文件 `.jks`,或者 `.keystore` 文件。
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
```bash
|
||||
keytool -genkey -v -keystore android/app/sky.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
|
||||
```
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
请记住你输入的主密码和键密码
|
||||
|
||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||
因为本项目将会发布2个以上的渠道,所以密钥库也会有2个以上,请注意区分 同一个发布渠道必须使用同一个密钥库,不要生成多个。
|
||||
|
||||
For help getting started with Flutter development, view the
|
||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
为了编译管理方便,我们将密钥库文件放在了项目代码内。
|
||||
|
||||
`key.properties` 文件用于存放密钥库的相关信息,但是我们不用这个文件,而是直接在 `build.gradle` 中写入密钥库的相关信息。
|
||||
因为我们将密钥库文件本身都已经储存在git中了,也就没必要再单独存放密钥信息了。
|
||||
|
||||
## 编译
|
||||
```bash
|
||||
flutter build apk --split-per-abi --release --flavor dev -t lib/main_dev.dart
|
||||
```
|
||||
|
||||
## 获取编译包的签名
|
||||
用于APP备案,国内商店上架等
|
||||
|
||||
需要使用到`apksigner`工具,对于Windows来说,它在:`C:\Users\myUser\AppData\Local\Android\Sdk\build-tools\34.0.0\lib`
|
||||
|
||||
在 `git bash` 中我需要使用 `apksigner.bat` 来使用它;在其它系统中应该可以直接使用 `apksigner` 命令即可。
|
||||
|
||||
参阅:[How to find signature of apk file?](https://stackoverflow.com/questions/38558623/how-to-find-signature-of-apk-file)
|
||||
|
||||
```bash
|
||||
apksigner verify --print-certs -v build/app/outputs/flutter-apk/app-sky-release.apk
|
||||
```
|
||||
|
||||
8
star_lock/android/.gitignore
vendored
8
star_lock/android/.gitignore
vendored
@ -8,6 +8,8 @@ GeneratedPluginRegistrant.java
|
||||
|
||||
# Remember to never publicly share your keystore.
|
||||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
|
||||
key.properties
|
||||
**/*.keystore
|
||||
**/*.jks
|
||||
# 因为我们要管理多个项目,所以这里不要忽略keystore
|
||||
# 而且我们的代码库是私有的,不存在泄露问题
|
||||
#key.properties
|
||||
#**/*.keystore
|
||||
#**/*.jks
|
||||
|
||||
@ -28,7 +28,27 @@ apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
|
||||
signingConfigs {
|
||||
pre {
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
}
|
||||
sky {
|
||||
// CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown
|
||||
storeFile file("sky.jks")
|
||||
storePassword 'sky2028'
|
||||
keyAlias = 'upload'
|
||||
keyPassword 'sky0s9x'
|
||||
}
|
||||
xhj {
|
||||
storeFile file("xhj.jks")
|
||||
storePassword 'xhj8872'
|
||||
keyAlias = 'upload'
|
||||
keyPassword 'xhj3md9'
|
||||
}
|
||||
}
|
||||
// ----- BEGIN flavorDimensions (autogenerated by flutter_flavorizr) -----
|
||||
flavorDimensions "flavor-type"
|
||||
|
||||
@ -46,18 +66,21 @@ android {
|
||||
sky {
|
||||
dimension "flavor-type"
|
||||
applicationId "com.skychip.lock"
|
||||
signingConfig signingConfigs.sky
|
||||
resValue "string", "app_name", "锁通通"
|
||||
}
|
||||
xhj {
|
||||
dimension "flavor-type"
|
||||
applicationId "com.xhjcn.lock"
|
||||
signingConfig signingConfigs.xhj
|
||||
resValue "string", "app_name", "鑫锁"
|
||||
}
|
||||
}
|
||||
|
||||
// ----- END flavorDimensions (autogenerated by flutter_flavorizr) -----
|
||||
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
lintOptions{
|
||||
@ -81,7 +104,6 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "cn.starlock.lock"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
||||
@ -92,37 +114,35 @@ android {
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
||||
signingConfig signingConfigs.pre
|
||||
// 为减少体积,使用不同架构分包发布编译选项 flutter build apk --split-per-abi
|
||||
// 所以需要禁用ndk在同一个个包中包含多个架构
|
||||
ndk {
|
||||
//设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
|
||||
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
|
||||
// abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
|
||||
}
|
||||
// armeabi 是 32位的,armeabi-v7a 是 32位的,arm64-v8a 是 64位的
|
||||
// armeabi: 第5代、第6代的ARM处理器,早期的手机用的比较多。
|
||||
// armeabi-v7a: 第7代及以上的 ARM 处理器。
|
||||
// arm64-v8a: 第8代、64位ARM处理器,2016年之后中高端的手机,比如骁龙8系列,麒麟9系列,联发科1000+等。
|
||||
// x86: 平板、模拟器用得比较多。
|
||||
// x86_64: 64位的平板。
|
||||
// 2011年以后生产的机子基本上都是armeabi-v7a 及以上了
|
||||
splits {
|
||||
abi {
|
||||
enable true
|
||||
reset()
|
||||
include 'armeabi-v7a', 'arm64-v8a'
|
||||
universalApk false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
}
|
||||
debug {
|
||||
storeFile file("starlock.keystore")
|
||||
storePassword '123456'
|
||||
keyAlias = 'starlock'
|
||||
keyPassword '123456'
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.release
|
||||
productFlavors.sky.signingConfig signingConfigs.sky
|
||||
productFlavors.xhj.signingConfig signingConfigs.xhj
|
||||
}
|
||||
debug {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --debug` works.
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
star_lock/android/app/sky.jks
Normal file
BIN
star_lock/android/app/sky.jks
Normal file
Binary file not shown.
BIN
star_lock/android/app/starlock.keystore
Normal file
BIN
star_lock/android/app/starlock.keystore
Normal file
Binary file not shown.
BIN
star_lock/android/app/xhj.jks
Normal file
BIN
star_lock/android/app/xhj.jks
Normal file
Binary file not shown.
@ -33,6 +33,7 @@ flavors:
|
||||
icon: "assets/icon/dev.png"
|
||||
android:
|
||||
applicationId: "com.starlock.lock.dev"
|
||||
|
||||
pre:
|
||||
app:
|
||||
name: "星锁"
|
||||
@ -45,10 +46,14 @@ flavors:
|
||||
icon: "assets/icon/sky.png"
|
||||
android:
|
||||
applicationId: "com.skychip.lock"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.sky
|
||||
xhj:
|
||||
app:
|
||||
name: "鑫锁"
|
||||
icon: "assets/icon/xhj.png"
|
||||
android:
|
||||
applicationId: "com.xhjcn.lock"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.xhj
|
||||
ide: idea
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user