Android ADB 安装失败,INSTALL_FAILED_TEST_ONLY
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25274296/
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
ADB Install Fails With INSTALL_FAILED_TEST_ONLY
提问by evve
I am having issues installing an apk to my device.
我在将 apk 安装到我的设备上时遇到问题。
adb install <.apk>
Using the above command returns the following:
使用上述命令返回以下内容:
5413 KB/s (99747 bytes in 0.017s)
pkg: /data/local/tmp/AppClient.TestOnly.App3.apk
Failure [INSTALL_FAILED_TEST_ONLY]
Any idea on what might cause this issue?
关于可能导致此问题的任何想法?
It definitely recognizes the device. Could it be an issue with the apk?
它肯定会识别该设备。会不会是apk的问题?
回答by Saurabh Meshram
Looks like you need to modify your AndroidManifest.xml
Change android:testOnly="true"
to android:testOnly="false"
or remove this attribute.
像你看起来需要修改AndroidManifest.xml
变更android:testOnly="true"
到android:testOnly="false"
或删除这个属性。
If you want to keep the attribute android:testOnly
as true
you can use pm install
command with -t
option, butyou may need to push
the apk to device first.
如果您想保留属性,android:testOnly
因为true
您可以使用pm install
带有-t
选项的命令,但您可能需要push
先将 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
I was able to reproduce the same issue and the above solved it.
我能够重现同样的问题,上面解决了它。
If your APK is outside the device (on your desktop), then below command would do it:
如果您的 APK 在设备外部(在您的桌面上),那么下面的命令将执行此操作:
$ adb install -t hello.apk
回答by Gabriel Morin
I had a similar problem with Android Studio 3.0.0 Beta 7
and could not publish anymore to the play store.
我遇到了类似的问题,Android Studio 3.0.0 Beta 7
无法再发布到 Play 商店。
As stated here: https://developer.android.com/studio/run/index.html
如此处所述:https: //developer.android.com/studio/run/index.html
Note: The Run button builds an APK with testOnly="true", which means the APK can only be installed via adb (which Android Studio uses). If you want a debuggable APK that people can install without adb, select your debug variant and click Build > Build APK(s).
注意:运行按钮构建一个带有 testOnly="true" 的 APK,这意味着 APK 只能通过 adb(Android Studio 使用的)安装。如果您想要一个无需 adb 即可安装的可调试 APK,请选择您的调试变体并单击 Build > Build APK(s)。
Same goes for release build, with Android Studio 3
you need to go to Build > Build APK(s)
to have a non testable release apk that you can submit to the store.
发布版本也是如此,Android Studio 3
您需要去Build > Build APK(s)
拥有一个不可测试的发布 apk,您可以将其提交给商店。
回答by sunqi228
Add -t
install flag, as on the screenshot below:
添加-t
安装标志,如下图所示:
回答by Eugene Voronoy
In my case this mistake was in unstable gradle version. Just use a stable version of gradle (not alpha, not even beta). And it was fixed for me
在我的情况下,这个错误是在不稳定的 gradle 版本中。只需使用稳定版本的 gradle(不是 alpha,甚至不是 beta)。它对我来说是固定的
回答by Linyun Liu
After searching and browsing all day, the only one works is adding
搜索浏览了一整天,唯一的作品就是添加
android.injected.testOnly=false
to the gradle.propertiesfile
到gradle.properties文件
回答by Patrick Maroney
I agree with Elisey. I got this same error after opening my project in the 2.4 preview and then opening the same project in android studio 2.3
我同意爱丽丝。在 2.4 预览版中打开我的项目,然后在 android studio 2.3 中打开同一个项目后,我遇到了同样的错误
Fixed the issue by changing this line in build.gradle from
通过更改 build.gradle 中的这一行来解决此问题
classpath 'com.android.tools.build:gradle:2.4.0-alpha5'
to
到
classpath 'com.android.tools.build:gradle:2.3.1'
回答by Hardian
Android studio 3.0 generates test only APK.
Android studio 3.0 生成仅测试 APK。
I have solved the issue by adding the "android:testOnly" property to android manifest's tag.
我已经通过将“android:testOnly”属性添加到 android manifest 的标签解决了这个问题。
<application
.....
android:testOnly="false"
android:theme="@style/AppTheme">
And then generated the APK by Android studio3.0 menu:Build-->Build APK(s).
然后通过Android studio3.0菜单生成APK:Build-->Build APK(s)。
More Info:https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
更多信息:https : //commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
回答by nick lee
add this line to your ‘gradle.properties'
将此行添加到您的“gradle.properties”
android.injected.testOnly=false
回答by us_david
None of the previous post solve my issue. Here is what's happening with me:
I normally load the app from android studio by clicking on the "Run" button. When you do this, android would create an app that's good for debug but not for install. If you try to install using:
以前的帖子都没有解决我的问题。这是我的情况:
我通常通过单击“运行”按钮从 android studio 加载应用程序。当你这样做时,android 会创建一个适合调试但不适合安装的应用程序。如果您尝试使用以下方法安装:
adb install -r yourapk
adb install -r yourapk
you will get a message that says:
您将收到一条消息,内容为:
Failure [INSTALL_FAILED_TEST_ONLY]
失败 [INSTALL_FAILED_TEST_ONLY]
When this happens, you will need to rebuilt the apk by first clean the build, then select Build->Build APK. See the image bellow:
发生这种情况时,您需要先清理构建,然后选择 Build->Build APK 来重建 apk。见下图:
This APK is ready to be installed either through adb install command or any other methods
此 APK 已准备好通过 adb install 命令或任何其他方法安装
Hope this helps
希望这可以帮助
David
大卫
回答by lujop
In my case was by uploading an APK, that although it was signed with production certificate and was a release variant, was generated by the run play button from Android studio. Problem solved after generating APK from Gradle or from Build APK menu option.
在我的例子中是通过上传一个 APK,虽然它是用生产证书签名的并且是一个发布变体,但它是由 Android Studio 的运行播放按钮生成的。从 Gradle 或从 Build APK 菜单选项生成 APK 后问题已解决。