ADB Install Fails With INSTALL_FAILED_TEST_ONLY
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?
Solution 1:
Looks like you need to modify your AndroidManifest.xml
Change android:testOnly="true"
to android:testOnly="false"
or remove this attribute.
If you want to keep the attribute android:testOnly
as true
you can use pm install
command with -t
option, but you may need to push
the apk to device first.
$ 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:
$ adb install -t hello.apk
Solution 2:
I had a similar problem with Android Studio 3.0.0 Beta 7
and could not publish anymore to the play store.
As stated here: 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).
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.
Solution 3:
Add -t
install flag, as on the screenshot below: