ADB Install Fails With INSTALL_FAILED_TEST_ONLY

2019-01-07 05:18发布

I am having issues installing an apk to my device.

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?

22条回答
对你真心纯属浪费
2楼-- · 2019-01-07 05:37

After searching and browsing all day, the only one works is adding

android.injected.testOnly=false

to the gradle.properties file

查看更多
做个烂人
3楼-- · 2019-01-07 05:38

As mentioned in documentation:

Android Studio automatically adds this attribute when you click Run

So, to be able to install your apk with adb install <path to apk file> you need to assemble build from terminal: ./gradlew assembleDebug and install with adb. Or just run ./gradlew installDebug to build and install on the device simultaneously.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-01-07 05:39

this works for me adb install -t myapk.apk

查看更多
Explosion°爆炸
5楼-- · 2019-01-07 05:40

Add -t install flag, as on the screenshot below:

answer is in the red box

查看更多
趁早两清
6楼-- · 2019-01-07 05:40

My finding is as below. If I compile using the Android Studio UI, and the APK generated, I can't just

adb install <xxx.apk>

It will generate Failure [INSTALL_FAILED_TEST_ONLY]

I need to compile it using the gradle i.e. ./gradlew app:assembleRelease. Then only the generated apk, then it can only be installed.

This is because the Android Studio UI Compile, only generate test apk for a particular device, while ./gradlew app:assembleRelease command is the actual apk generation to be installed on all device (and upload to playstore)

查看更多
Evening l夕情丶
7楼-- · 2019-01-07 05:42

Although I am sure Saurabh's answer will work for most other people, I did want to identify the extra steps I had to take in order to get my apk installed.

I tried pushing to the device with the following result:

? adb push AppClient.TestOnly.App3.apk \tmp\
failed to copy 'AppClient.TestOnly.App3.apk' to '\tmp\': Read-only file system

After looking around to change the filesystem RW permissions I ended up executing the following commands:

? adb shell
255|shell@android:/ $ su
shell@android:/ # mount -o remount,rw /
mount -o remount,rw /

I got this when I tried to push again:

? adb push AppClient.TestOnly.App3.apk /tmp
failed to copy 'AppClient.TestOnly.App3.apk' to '/tmp': Permission denied

I was able to push to the sdcard:

? adb push AppClient.TestOnly.App3.apk /sdcard/
3178 KB/s (99747 bytes in 0.030s)

At which point I was able to execute Saurabh's command:

shell@android:/ # pm install -t /sdcard/AppClient.TestOnly.App3.apk
pm install -t /sdcard/AppClient.TestOnly.App3.apk
        pkg: /sdcard/AppClient.TestOnly.App3.apk
Success
查看更多
登录 后发表回答