ADB Install Fails With INSTALL_FAILED_TEST_ONLY
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
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.