Android 配置 Eclipse 以使用签名密钥库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10886814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configure Eclipse to use signed keystore
提问by richey
I have finally created a 'final' keystore for my app. As my app is using Google Maps, I take I have to update all Layouts to use the new API Key resulting from the app as well..
我终于为我的应用程序创建了一个“最终”密钥库。由于我的应用程序使用的是谷歌地图,我认为我必须更新所有布局才能使用应用程序生成的新 API 密钥。
Now I'm fully aware of the requirement to export a signed APK for release, but what after that? My thoughts are that for further development and testing, it would be easiest if I could configure Eclipse to use my final keystore instead of the debug keystore … but I found no way to do that? It only allows me to configure an 'alternative' debug key but I guess that's not the same.
现在我完全了解导出已签名的 APK 以供发布的要求,但在那之后呢?我的想法是,为了进一步的开发和测试,如果我可以将 Eclipse 配置为使用我的最终密钥库而不是调试密钥库,那将是最简单的……但我发现没有办法做到这一点?它只允许我配置一个“替代”调试键,但我想这不一样。
Sorry if I am too confused if I have totally misunderstood something here.
对不起,如果我在这里完全误解了一些东西,我太困惑了。
回答by Devunwired
You can configure a custom keystore to use for your debug builds (the ones that happen when you click Run...) in Eclipse by going to Preferences -> Android -> Build and entering the file name in the "Custom debug keystore" option.
您可以通过转到 Preferences -> Android -> Build 并在“Custom debug keystore”选项中输入文件名,在 Eclipse 中配置一个自定义密钥库以用于您的调试构建(当您单击 Run... 时发生的那些) .
However, it has the caveat that it must follow the same rules as a traditional debug keystore, mainly:
但是,它有一个警告,它必须遵循与传统调试密钥库相同的规则,主要是:
- The keystore password must be "android"
- It must contain a key named "androiddebugkey"
- That key's password must be "android"
- 密钥库密码必须是“android”
- 它必须包含一个名为“androiddebugkey”的键
- 该密钥的密码必须是“android”
Therefore, while it is possible to sign your apps in debug with the same keystore as you Export with, it requires your production keystore to look like a debug store, which makes it less secure if someone got ahold if the file (it would be easier to inspect and guess the passwords).
因此,虽然可以使用与导出相同的密钥库对您的应用程序进行签名,但它要求您的生产密钥库看起来像一个调试存储库,如果有人持有文件(这会更容易),这会降低安全性检查和猜测密码)。
HTH
HTH
回答by pilcrowpipe
I was able to to use my Google Play release keystore as my custom debug keystore to help with debugging in-app purchase functionality. The same could no doubt be applied to debugging Google Maps stuff as well.
我能够使用我的 Google Play 发布密钥库作为我的自定义调试密钥库来帮助调试应用内购买功能。毫无疑问,这同样适用于调试谷歌地图的东西。
As Devunwired mentioned, there are caveats. But my solution was this:
正如Devunwired 所提到的,有一些警告。但我的解决方案是这样的:
- Copy your release key somewhere.
- Change the keystore password/key password and key alias following the instructions here(also, following Devunwired's recommendations to make it look like a debug keystore).
- Change Eclipse's Preferences > Android > Build > Custom keystore setting to the path of the copy made in step 1.
- Done!
- 将您的发布密钥复制到某处。
- 按照此处的说明更改密钥库密码/密钥密码和密钥别名(另外,按照 Devunwired 的建议使其看起来像调试密钥库)。
- 将 Eclipse 的 Preferences > Android > Build > Custom keystore 设置更改为在步骤 1 中创建的副本的路径。
- 完毕!
回答by Steven Craft
In order for Eclipse to sign automatically for you when you deploy you need to set up a keystore which behaves like the debug keystore. This means there must be an 'androiddebugkey' and both the key and keystore password must be 'android'. Therefore, I'd recommend the following:
为了让 Eclipse 在您部署时自动为您签名,您需要设置一个密钥库,其行为类似于调试密钥库。这意味着必须有一个“androiddebugkey”并且密钥和密钥库密码都必须是“android”。因此,我建议如下:
- Make a copy of your keystore, I copied mine to a file called iap.keystore
- Open terminal/command window with keytool on the path (for me the path is D:\NVPACK\jdk1.6.0_45\bin\keytool.exe) or use the fullpath to
keystore
in the commands below - Change your keystore password to 'android':
keytool -storepasswd -keystore iap.keystore
- Follow prompt to enter your old keystore password
- Follow prompt to enter
android
as the new password - Follow prompt to confirm
android
as the password
- Rename your key to
androiddebugkey
(replaceOld_Key_Store_Name
with your current key name in the next command)keytool -changealias -keystore iap.keystore -alias Old_Key_Store_Name -destalias androiddebugkey
- Follow prompt to enter your keystore password (which is now
andorid
) - Follow prompt to enter your
Old_Key_Store_Name
password (this is whatever you previously had your key password set to)
- Change the password for your
androiddebugkey
keytool -keypasswd -keystore iap.keystore -alias androiddebugkey
- Follow prompt to enter your keystore password (which is now
andorid
) - Follow prompt to enter your
androiddebugkey
password (this is whatever you previously had your key password set to) - Follow prompt to enter
android
as the new key password - Follow prompt to confirm
android
as the key password
- You now have a keystore (with key) which Eclipse can use to automatically sign builders.
- Load up Eclipse.
- Window -> Preferences -> Android -> Build
- Follow 'Custom debug keystore' browse to the iap.keystore file we previous created
- OK
- 复制您的密钥库,我将我的复制到名为 iap.keystore 的文件中
- 在路径上使用 keytool 打开终端/命令窗口(对我来说路径是 D:\NVPACK\jdk1.6.0_45\bin\keytool.exe)或
keystore
在下面的命令中使用完整路径 - 将您的密钥库密码更改为“android”:
keytool -storepasswd -keystore iap.keystore
- 按照提示输入旧的密钥库密码
- 按照提示输入
android
新密码 - 按照提示确认
android
密码
- 将您的密钥重命名为
androiddebugkey
(在下一个命令中替换Old_Key_Store_Name
为您当前的密钥名称)keytool -changealias -keystore iap.keystore -alias Old_Key_Store_Name -destalias androiddebugkey
- 按照提示输入您的密钥库密码(现在是
andorid
) - 按照提示输入您的
Old_Key_Store_Name
密码(这是您之前设置的密钥密码)
- 更改您的密码
androiddebugkey
keytool -keypasswd -keystore iap.keystore -alias androiddebugkey
- 按照提示输入您的密钥库密码(现在是
andorid
) - 按照提示输入您的
androiddebugkey
密码(这是您之前设置的密钥密码) - 按照提示输入
android
新的密钥密码 - 按照提示确认
android
为密钥密码
- 您现在拥有一个密钥库(带有密钥),Eclipse 可以使用它来自动签署构建器。
- 加载 Eclipse。
- 窗口 -> 首选项 -> Android -> 构建
- 按照“自定义调试密钥库”浏览到我们之前创建的 iap.keystore 文件
- 好的
Now when you launch/debug your project, it'll use the keystore we just set up to sign your project. This will allow things like IAP to work.
现在,当您启动/调试您的项目时,它将使用我们刚刚设置的密钥库来签署您的项目。这将允许 IAP 之类的东西工作。
BEWARE:this is convenient, but of course if someone gets hold of your iap.keystore they will be able to sign things as you by using 'android' as the keystore/key password. Hopefully this is obviously from the steps listed above, but just take a second to appreciate what this means for yourself (or your company). Then based on that decide if the risks are acceptable, and if you need to carry out any extra measures to ensure the safety of this file.
当心:这很方便,但当然,如果有人掌握了您的 iap.keystore,他们将能够使用“android”作为密钥库/密钥密码来为您签名。希望这显然来自上面列出的步骤,但请花点时间了解这对您自己(或您的公司)意味着什么。然后基于此决定风险是否可以接受,以及是否需要执行任何额外的措施来确保此文件的安全。
回答by Vinod Joshi
We set custom keystore to use for our debug builds. Eclipse Go to Preferences -> Android -> Build and ent the file name in the "Custom debug keystore".
我们设置自定义密钥库以用于我们的调试版本。Eclipse 转到 Preferences -> Android -> Build 并在“自定义调试密钥库”中输入文件名。
Important when we create our keystore for eclipse customs.:
当我们为日食习俗创建密钥库时很重要。:
The keystore password must be "android" It must contain a key named "androiddebugkey" That key's password must be "android" Therefore, while it is possible to sign your apps in debug with the same keystore as you Export with, it requires your production keystore to look like a debug store, which makes it less secure if someone got ahold if the file (it would be easier to inspect and guess the passwords).
密钥库密码必须是“android” 它必须包含一个名为“androiddebugkey”的密钥 该密钥的密码必须是“android”密钥库看起来像一个调试存储,如果有人拿到文件,这会降低它的安全性(检查和猜测密码会更容易)。
if we want to change the keystore password: $ keytool -storepasswd -keystore my.keystore
如果我们想更改密钥库密码: $ keytool -storepasswd -keystore my.keystore
if we want to change the keystore alias password: $ keytool -keypasswd -keystore my.keystore -alias my_name
如果我们想更改密钥库别名密码: $ keytool -keypasswd -keystore my.keystore -alias my_name
if we want to change the keystore alias: $ keytool -changealias -keystore my.keystore -alias my_name -destalias my_new_name
如果我们想更改密钥库别名: $ keytool -changealias -keystore my.keystore -alias my_name -destalias my_new_name
Vkj
Vkj
回答by Tiberius
You can enter both your debug and your release SHA1 for the same Google API key using the Google Developers Console (console.developers.google.com).
您可以使用 Google Developers Console (console.developers.google.com) 为同一个 Google API 密钥输入调试和发布 SHA1。
This way, you will have the same API key for both and will no longer have to change it in the AndroidManifest.xml.
这样,您将拥有相同的 API 密钥,并且不再需要在 AndroidManifest.xml 中更改它。
回答by Sabo
We have the same problem some time ago at our office. Since we needed this quite often we wrote a simple script to make it easy to to convert release keystores to debug ones.
我们前段时间在我们的办公室也遇到了同样的问题。由于我们经常需要这个,我们编写了一个简单的脚本来轻松地将发布密钥库转换为调试密钥库。
The script is available on https://github.com/IntellexApps/key2debug
该脚本可在https://github.com/IntellexApps/key2debug 上找到
We are using it for some time now, so should be quite stable.
我们现在使用它有一段时间了,所以应该很稳定。
cheers!
干杯!
回答by Alex R. R.
Here there are the instructions to convert a regular keystore in a debug keystore: https://stackoverflow.com/a/15754187/917362
以下是在调试密钥库中转换常规密钥库的说明:https: //stackoverflow.com/a/15754187/917362