简体   繁体   English

由于应用程序签名不同,重新安装失败

[英]Re-installation failed due to different application signatures

I am getting the above error message when I try to debug an application that is already installed. 当我尝试调试已安装的应用程序时,出现上述错误消息。 Most others who run into this seem to be developing on different machines with different key files, but I am doing everything on the same box. 遇到此问题的大多数其他人似乎是在具有不同密钥文件的不同机器上开发的,但是我正在同一盒子上进行所有操作。

My issue is that I am testing my database upgrade process (ie what the onUpgrade() method of my SQLiteOpenHelper extension does). 我的问题是我正在测试数据库升级过程(即SQLiteOpenHelper扩展的onUpgrade()方法做什么)。 For this, I would like to try the upgrade on top of a variety of older builds. 为此,我想尝试在各种较旧的版本之上进行升级。 These builds are available as signed application packages. 这些版本可以作为已签名的应用程序包使用。 When I deploy such a package to a fresh emulator and then try to debug the current version on top, I get the error in the subject line. 当我将这样的程序包部署到新的仿真器,然后尝试在顶部调试当前版本时,在主题行出现错误。 I think that this is because the debug deployment packages are unsigned, and the currently installed package is signed. 我认为这是因为调试部署程序包是未签名的,而当前安装的程序包是已签名的。 Again, I know that the error goes away if I unstall the currently installed app, but then I cannot test the upgrade. 再一次,我知道如果我停止当前安装的应用程序,该错误就会消失,但是随后我将无法测试升级。

I do not want to go through the effort of switching back my dev environment to older build versions, so that I can build unsigned packages for these versions. 我不想经历将开发环境切换回旧版本的工作,因此我可以为这些版本构建未签名的程序包。 I may not even be able to do this, because I switched source code repositories recently and lost some of the history. 我什至无法执行此操作,因为我最近切换了源代码存储库并丢失了一些历史记录。

I believe that if I were able to get Eclipse to generate a signed package for debugging, it should work. 我相信,如果我能够让Eclipse生成签名的包进行调试,那么它应该可以工作。 Alternatively, I could manually deploy a signed package and launch a debug session without a build/deployment step, but I have not been to figure out if this is possible, either. 另外,我可以手动部署已签名的程序包并启动调试会话,而无需进行构建/部署步骤,但是我也没有弄清楚这是否可行。 What can I do? 我能做什么?

Edit: The Android documentation was helpful in figuring out how to sign a package with the debug key, but this does not help me, because I need to debug with a private key. 编辑: Android文档有助于弄清楚如何使用调试密钥对软件包进行签名,但这对我没有帮助,因为我需要使用私钥进行调试。 I suppose that this is not possible. 我想这是不可能的。

You can sign current package with release key, install on device, run the application and connect debugger in Eclipse. 您可以使用发布密钥对当前软件包进行签名,在设备上安装,运行应用程序并在Eclipse中连接调试器。 How to connect debugger: in the DDMS perspective on the Devices view select your application and press button with "green bug": 如何连接调试器:在“设备”视图的DDMS透视图中,选择您的应用程序并按下带有“绿色错误”的按钮:

在此处输入图片说明

I'll post it as an answer: 我将其发布为答案:

You should generate them all with one signature - otherwise it wont work. 您应该使用一个签名来生成所有签名-否则它将无法正常工作。 only uninstall and fresh install will work with different signatures. 只有卸载和全新安装才能使用不同的签名。 http://developer.android.com/guide/publishing/app-signing.html also taken from there: http://developer.android.com/guide/publishing/app-signing.html也是从那里获取的:

Eclipse Users If you are developing in Eclipse/ADT (and have set up Keytool and Jarsigner as described above in Basic Setup for Signing), signing in debug mode is enabled by default. Eclipse用户 如果您正在Eclipse / ADT中进行开发(并且已经按照上面的“签名的基本设置”中的说明设置了Keytool和Jarsigner),则默认启用调试模式下的签名。 When you run or debug your application, ADT signs the .apk with the debug certificate, runs zipalign on the package, then installs it on the selected emulator or connected device. 在运行或调试应用程序时,ADT将使用调试证书对.apk进行签名,在程序包上运行zipalign,然后将其安装在选定的仿真器或连接的设备上。 No specific action on your part is needed, provided ADT has access to Keytool. 只要ADT有权使用Keytool,就不需要您采取任何具体措施。

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

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