我有一个程序在Android模拟器工作。我不时地创建一个签名的。apk,并将其导出到我的HTC Desire进行测试。一切都很好。

在我最新导出的。apk上,当我试图安装。apk时,我得到错误消息“应用程序未安装”。它在模拟器上运行良好。

因为我主要是在模拟器上测试,只是时不时地导出到真正的手机上,我不确定这是什么时候发生的。什么可能的原因,它不安装在物理手机,但运行良好的模拟器?

我已经尝试重新启动电话并删除现有的。apk,并不能解决这个问题。


当前回答

通过命令行创建keystore文件

keytool -genkey -alias key_file_name.keystore -keyalg RSA -validity 1000000000000000 -keystore key_file_name.keystore

通过Eclipse导出apk,右键单击Android项目Android Tools >导出签名应用程序包,然后给出密钥库位置和密码。

这将crate signed apk,同时apk将被zipaligned。和安装。

如果你通过命令行全部,有时你可能会遇到“应用程序未安装”错误。 (应用程序未安装错误不仅会发生在使用命令行时。也可能是其他原因)

其他回答

当我安装到的设备没有足够的存储空间时,我遇到过这个“应用程序未安装”错误。删除几个文件就可以安装应用程序了。奇怪的是,它没有给我一个“空间不足”的消息。(注:我是从一个“未知”位置手动安装apk。)

I had a similar situation.I was able to install app in debug mode using USB but not a signed version. I was able to install signed version on other phone, but not on my device. Numerous reasons and solutions did not help me. But one direction I got from a solution "uninstall for all users". What I did is to again install app in debug mode using USB connection, go to app details and "uninstall for all users" from right top 3 dots - to remove debug version. This looks like cleared all kinds of references. I usually do a normal uninstall.

现在我能够在设备上获得签名APK并成功安装。

如果内部内存中没有足够的空间,也会发生这种情况。我有500Mb的空闲空间,但这还不够。免费试用1Gb以上。

就我而言,这是因为我使用的是支持库28的alpha版本。看起来谷歌将这些预发布版本标记为testOnly。如果你真的想这样发布(例如,你想像我一样推出一个内部测试),你可以将这一行添加到你的gradle中。属性文件:

android.injected.testOnly=false

我有同样类型的错误,这是由我的android manifest XML文件中的这一行引起的。

android:permission="android.permission.INSTALL_LOCATION_PROVIDER"

我去掉了那条线,问题就解决了。希望这能有所帮助