简体   繁体   English

如何配置构建文件以获取Android应用的发布密钥和密钥库文件的密码

[英]How to configure the build file to obtain password for release key and keystore file for Android apps

I would like to upload an Android app for the first time so I am reading the Signing Your Applications guide but one thing is not so clear, therefore I would appreciate if somebody could explain me the below note: 我想首次上传Android应用程序,因此我正在阅读“ 签署应用程序指南”,但有一点不清楚,因此,如果有人可以向我解释以下注意事项,我将不胜感激:

Note: Including the passwords for your release key and keystore inside the build file is not a good security practice. 注意:在构建文件中包括发布密钥和密钥库的密码不是一种好的安全做法。 Alternatively, you can configure the build file to obtain these passwords from environment variables or have the build process prompt you for these passwords. 或者,您可以配置构建文件以从环境变量获取这些密码,或者让构建过程提示您输入这些密码。

To obtain these passwords from environment variables: 要从环境变量获取这些密码:

storePassword System.getenv("KSTOREPWD")
keyPassword System.getenv("KEYPWD")

What are environment variables? 什么是环境变量? And what do I need to do exactly with these variables? 我需要对这些变量做些什么? Or I don't need to care about them if I am signing my app in Android Studio? 或者,如果我在Android Studio中对我的应用程序进行签名,则不需要关心它们吗?

You really dont need to care about the environment variables. 您真的不需要关心环境变量。 When you go to build your project from Android Studio you should be prompted for your keystore location and for the password. 当您从Android Studio构建项目时,系统会提示您输入密钥库位置和密码。 Just select the correct file and enter the correct password and that is all. 只需选择正确的文件,然后输入正确的密码即可。

Environmental Variables are variables that the OS exposes to programs it runs to help define the environment. 环境变量是操作系统公开给其运行的程序以帮助定义环境的变量 Some examples include PATH , which defines which directories will be searched when a program requests a non-fully qualified path (ie doesn't start with / or C:\\\\ ) after it searches the PWD , or current directory (another environmental variable). 一些示例包括PATH ,它定义了在搜索PWD之后程序请求非完全限定路径(即,不以/C:\\\\开头)时搜索哪些目录,或当前目录(另一个环境变量)。 。 What this tutorial is saying is that you can configure your build file to fetch and use the values of KSTOREPWD and KEYPWD to get your key and sign your app. 本教程的意思是您可以配置构建文件以获取并使用KSTOREPWDKEYPWD的值来获取密钥并签署应用程序。 That being said, you don't really need to care about all this if you're signing your app through Android Studio; 话虽这么说,如果您通过Android Studio对应用程序进行签名,那么您实际上并不需要关心所有这一切; you would if you were signing from the command line or wanted to batch-sign a bunch of apps. 如果您是从命令行进行签名,或者想要对一堆应用程序进行批量签名,则会遇到这种情况。 Just make sure you don't put the passwords in your build file 只要确保您没有在构建文件中输入密码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM