一:
在命令行运行,后会生成upload-keystore-anyou.jks文件,这个文件名自己定义:
keytool -genkey -v -keystore E:/jks/uploadcar01.jks -keyalg RSA -keysize 2048 -validity 10000 -alias uploadcar01
密钥自己准备一个:mycarab
将.jks文件拷贝到android跟目录下, jks文件名和 上面的-alias后面的名字一致。
二:在文件 android/local.properties中添加:
storePassword=mycarab
keyPassword=mycarab
keyAlias=uploadcar01
storeFile=../uploadcar01.jks
三:在 android/app/build.gradle文件里面的 android节点里面添加:
signingConfigs {
release {
keyAlias localProperties['keyAlias']
keyPassword localProperties['keyPassword']
storeFile localProperties['storeFile'] ? file(localProperties['storeFile']) : null
storePassword localProperties['storePassword']
}
debug {
keyAlias localProperties['keyAlias']
keyPassword localProperties['keyPassword']
storeFile localProperties['storeFile'] ? file(localProperties['storeFile']) : null
storePassword localProperties['storePassword']
}
}
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
}
debug {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
四: flutter run --release
大功告成,可以在命令行打包apk了
flutter build apk --release --no-sound-null-safety
权限配置:
android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
图标更改:
android/app/src/main/AndroidManifest.xml
<application
android:label="车测试"
android:name="${applicationName}"
android:icon="@mipmap/ic_car">
keytool -list -v -keystore uploadcar01.jks
查看jks文件内容
添加启动图片:
android\app\src\main\res\drawable\launch_background.xml
中添加:
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/welcome" />
</item>