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

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

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

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


当前回答

尝试在AndroidManifest.xml中进行更改:

设置debuggable为true 签署apk

其他回答

我也遇到过这个问题。 请尝试这个解决方案。确保您的项目的包名称不同于您的移动电话中已经安装的以前的项目。我觉得他们的名字有冲突。它在我身上起作用。

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

android.injected.testOnly=false

对于那些使用Android Studio 3的人。

Suryanarayana Reddy的答案是正确的,尽管它没有说明解决问题的步骤,因此。

在你的AndroidManifest.xml的应用标签下添加testOnly="false"和android:debuggable="true",就像这样:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:testOnly="false"
    android:debuggable="true"
    >

然后在AndroidStudio的菜单栏Build > Build APK(s)

打开AndroidMainfest,然后在应用程序标签中添加verionCode, versionName,并确保debug able等于false:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="...">

<application
    ...
    android:debuggable="false"
    android:versionCode="1"
    android:versionName="1.0"
    tools:ignore="HardcodedDebugMode">
    ...
</application>

然后打开构建。gradle (module:app)确保verionCode, versionName退出和minsdk <=您的移动sdk:

defaultConfig {
    ...
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
   ...
}

查阅资料来源:https://developer.android.com/studio/publish/

https://developer.android.com/studio/publish/preparing &

https://developer.android.com/studio/publish/versioning &

和https://developer.android.com/studio/publish/app-signing

在我的例子中,这是因为Android Studio 3.0设置Android:testOnly="true"在apk上,从版本build Variant构建。

https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html

所以运行。/gradlew assemblerrelease来解决我的问题