您的位置:首页 > 教育 > 锐评 > 一元购网站建设多少钱_购物网站需求分析_5118关键词查询工具_北京网站推广公司

一元购网站建设多少钱_购物网站需求分析_5118关键词查询工具_北京网站推广公司

2024/10/6 2:23:14 来源:https://blog.csdn.net/nonagontech/article/details/142466103  浏览:    关键词:一元购网站建设多少钱_购物网站需求分析_5118关键词查询工具_北京网站推广公司
一元购网站建设多少钱_购物网站需求分析_5118关键词查询工具_北京网站推广公司

前言

我们需要将App进行数字签名才能发布到商店里。在这里就具体描述一下如果给App添加签名

为App签名

创建一个用户上传的秘钥库

如果你已经有一个秘钥库了,可以直接跳到下一步,如果没有则按照下面的指令创建一个

keytool 可能不在我们的系统路径中。它是 Java 的一部分,在安装 Android Studio 的时候会被一起安装。运行 flutter doctor -v,’Java binary at:’ 之后打印出来的就是它的路径,然后用 java 来替换以上命令中的 keytool,并加上 keytool 的完整路径即可。如果文件路径包含空格,类似 Program Files 这样的,请使用平台允许的命名规则。例如,在 Mac/Linux 上使用 Program\ Files,而在 Windows 上可以使用 "Program Files"

打开电脑终端执行以下指令

# macOS或者Linux系统上
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
#在windows系统上
keytool -genkey -v -keystore %userprofile%\upload-keystore.jks  -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload

从App中引用秘钥库

在项目/android/key.properties文件,它包含了密钥库的位置的定义。在替换内容时要去除< >括号。

storePassword和keyPassword的值都是上一步生成文件时我们自己输入的

storeFile 密钥路径在 macOS 上类似于 /Users/<user name>/upload-keystore.jks,在 Windows 上类似于 C:\\Users\\<user name>\\upload-keystore.jks

storePassword=<password-from-previous-step>
keyPassword=<password-from-previous-step>
keyAlias=upload
storeFile=<keystore-file-location>

在gradle中配置签名

在以 release 模式下构建你的应用时,修改 项目/android/app/build.gradle 文件,以通过 gradle 配置你的上传密钥

1.在 android 代码块之前将你 properties 文件的密钥库信息添加进去,将 key.properties 文件加载到 keystoreProperties 对象中。

   def keystoreProperties = new Properties()def keystorePropertiesFile = rootProject.file('key.properties')if (keystorePropertiesFile.exists()) {keystoreProperties.load(new FileInputStream(keystorePropertiesFile))}android {...}

2.找到 buildTypes 代码块:

   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.debug}}

将其替换为我们的配置内容:

   signingConfigs {release {keyAlias keystoreProperties['keyAlias']keyPassword keystoreProperties['keyPassword']storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : nullstorePassword keystoreProperties['storePassword']}}buildTypes {release {signingConfig signingConfigs.release}}

现在我们 app 的发布版本就会被自动签名了。

清理缓存

当你更改 gradle 文件后,也许需要运行一下 flutter clean。这将防止缓存的版本影响签名过程。

flutter clean
flutter pub get

打包指令

#abb格式
flutter build appbundle
#apk格式
flutter build apk

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com