我在我的设备上安装apk时有问题。

adb install <.apk>

使用上述命令将返回以下结果:

5413 KB/s (99747 bytes in 0.017s)
        pkg: /data/local/tmp/AppClient.TestOnly.App3.apk
Failure [INSTALL_FAILED_TEST_ONLY]

你知道是什么导致了这个问题吗?

它肯定能识别设备。会不会是apk出了问题?


当前回答

经过一整天的搜索和浏览,唯一的工作就是添加

android.injected.testOnly=false

去gradle。属性文件

其他回答

看起来你需要修改你的AndroidManifest.xml 将android:testOnly="true"更改为android:testOnly="false"或删除此属性。

如果你想保持android:testOnly属性为true,你可以使用pm install命令和-t选项,但你可能需要先将apk推到设备。

$ adb push bin/hello.apk /tmp/
5210 KB/s (825660 bytes in 0.154s)

$ adb shell pm install /tmp/hello.apk 
    pkg: /tmp/hello.apk
Failure [INSTALL_FAILED_TEST_ONLY]

$ adb shell pm install -t /tmp/hello.apk 
    pkg: /tmp/hello.apk
Success

我能够重现相同的问题,上面解决了它。

如果你的APK在设备外部(在你的桌面上),那么下面的命令可以做到:

$ adb install -t hello.apk

添加-t install标志,如下面的截图所示:

Android studio 3.0只生成测试APK。

我已经通过添加“android:testOnly”属性到android manifest的标签解决了这个问题。

 <application
    .....
    android:testOnly="false"
    android:theme="@style/AppTheme">

然后通过Android studio3.0菜单生成APK:Build—>Build APK(s)。

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

首先删除不稳定版本:

Adb卸载problem -package-name

; 然后重新安装apk。

以我为例,使用Android Studio 4.0解决了这个问题;

添加到gradle。属性的文件;

android.injected.testOnly=false