【Error】adb install 报错 INSTALL_FAILED_TEST_ONLY: installPackageLI

apk是android studio默认生成的apk,adb install时报错:

    Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

解决方法:

    adb install -t app-debug.apk  #允许安装test用的apk


原文

请转载的朋友表明出处:

http://blog.csdn.net/shift_wwx/article/details/78468397


平台版本是android 7.0,在adb install *.apk 会提示下面的错误:

 Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]


方法1:

修改AndroidManifest.xml 中android:testOnly="true" 改成 android:testOnly="false",或者直接去掉。


方法2:

adb push *.apk /tmp

adb shell pm install -t /tmp/*.apk


方法3:

adb install -t *.apk


方法4:

Android Studio 3.0 and FLAG_TEST_ONLY  一文中,给出了关于Android studio 3.0中出现问题的说明:

[html]  view plain  copy
  1. Option to indicate this application is only for testing purposes.  
  2. For example, it may expose functionality or data outside of itself that would cause a security hole, but is useful for testing.  
  3. This kind of application can not be installed without the INSTALL_ALLOW_TEST flag, which means only through adb install.  
[html]  view plain  copy
  1. 1. You cannot install an app with android:testOnly="true" by conventional means, such as from an Android file manager or from a download off of a Web site  
  2. 2. Android Studio 3.0 sets android:testOnly="true" on APKs that are run from the IDE  

解决办法:
在gradle.properties(项目根目录或者gradle全局配置目录 ~/.gradle/)文件中添加:
[html]  view plain  copy
  1. android.injected.testOnly=false  


参考文献:

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

https://stackoverflow.com/questions/25274296/adb-install-fails-with-install-failed-test-only


参考:https://blog.csdn.net/shift_wwx/article/details/78468397



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值