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
- Option to indicate this application is only for testing purposes.
- For example, it may expose functionality or data outside of itself that would cause a security hole, but is useful for testing.
- 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. 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. Android Studio 3.0 sets android:testOnly="true" on APKs that are run from the IDE
解決辦法: 在gradle.properties(項目根目錄或者gradle全局配置目錄 ~/.gradle/)檔案中添加: [html] view plain copy
- 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