ADB Install Fails With INSTALL_FAILED_TEST_ONLY
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:
Solution 4
In my case this mistake was in unstable gradle version. Just use a stable version of gradle (not alpha, not even beta). And it was fixed for me
Solution 5
After searching and browsing all day, the only one works is adding
android.injected.testOnly=false
to the gradle.properties file
Related videos on Youtube
evve
Updated on July 19, 2022Comments
-
evve almost 2 years
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?
-
evve almost 10 yearsI should add that some of this may not be necessary for others.
-
Saurabh Meshram almost 10 yearsAppreciate the extra effort!.
-
Reaz Murshed about 7 yearsSaved the day! Changed the gradle version from 2.4.0-alpha3 to 2.3.0
-
Ryan R almost 7 yearsThe price of sticking to the bleeding edge... Thanks!
-
BubbaGum almost 7 yearsThe sample project I compile use 'com.android.tools.build:gradle:2.4.0-alpha7' and does not compile with a stable version, only adding -t as mentioned solved the issue for me.
-
rmtheis over 6 yearsPlease explain what
-t
does. -
xiaoyee over 6 yearsin adb help, you will see install with -t means allow test packages
-
GPS over 6 yearsCan anyone confirm that setting android:testOnly="true" will fix it for unstable gradle versions too?
-
marioc64 over 6 yearsYou don't need to adb push and pm install, you can specify the -t switch just after the adb install command: adb install -t -r package.apk
-
Sky Kelsey over 6 yearsThis started happening with Android Studio 3.0, and your suggestion fixed it for me.
-
noamtm over 6 yearsI suspect that right now (Oct/Nov 2017) this is the correct answer for most people who get here. Before AS 3, the APK produced by "Run" was installable even outside of AS, no it is not.
-
Gene Bo over 6 yearsscreen is launched via clicking Edit Configurations on the module dropdown menu - between Make and Run, Debug buttons at top of IDE : developer.android.com/studio/run/rundebugconfig.html
-
Elye over 6 yearsRefers to medium.com/@elye.project/… to understand better of the issue.
-
Basim Sherif about 6 yearsThanks! This will fix spoon runner issue as well!
-
amIT about 6 yearsno need to push the apk anymore adding -t works in adb install works fine , for the full command check my answer below.
-
user3193413 almost 6 yearsThanks mate. It started after upgrading android gradle to 4. Deploying the app directly from android studio works fine but not if using the terminal (adb install etc..) After refreshing the gradle as you mentioned it worked.
-
sunil almost 6 years@user3193413 Nice to hear the post was of help
-
ruben over 5 yearsthere's update and there's some more tweak.. took me a while to figure it out :/
-
drulabs over 4 yearsYou are a lifesaver. I was having trouble with the release build (faulty keystore) and wanted to distribute debug builds to my testers.
-
HendraWD over 4 years
adb push bin/hello.apk /tmp/
doesn't work for me,adb push ./debug.apk /sdcard/temp/debug.apk
worked -
Joshua Pinter over 4 yearsIf you're using appium, you need to specify
"allowTestPackages": "true"
to your e2e scheme capabilities. -
Sulav Timsina over 4 years
adb install -t app/build/outputs/apk/usUnitedStates/debug/app-usUnited-debug.apk
worked for me. -
Julian about 4 yearsThanks. That solved my problem. My app was a system app. Thus -f was needed.
-f: Install package on the internal system memory.
-
Girish almost 4 years@JoshuaPinter Can you please elaborate where to put allowTestPackages": "true"
-
Joshua Pinter almost 4 years@Girish You add it to your Appium driver config, like
config.allowTestPackages = true
. Note, this only pertains to end to end tests using Appium. -
Prahlad V Thej almost 3 years@nicklee Would I be able to release this build on play-store with key set as android.injected.testOnly = false or should I revert it back to "true" when I am uploading to play-store?
-
Prahlad V Thej almost 3 yearsWould I be able to release this build on play-store with key set as android.injected.testOnly = false or should I revert it back to "true" when I am uploading to play-store?
-
Martin almost 3 yearsThe
android:testOnly="true"
is only set in the build/intermediates/**/AndroidManifest.xml files. So I never added the flag in the first case. -
Martin almost 3 years@prahlad-v-thej Pretty sure the opposite is true: Trying to upload an testOnly version to the Play-Store will fail. My suspicion is that Google added testOnly so you don't accidentally upload a version meant for debugging and testing to the store. Since I make clean builds before upload it doesn't matter to me.
-
Martin almost 3 yearsNo, that doesn't work — my test scripts do an uninstall automatically when the install fails.
-
Reza over 2 yearsPerfect. you saved my time. I had the same problem that I sent debug apk in outputs folder of project. I didn't know that I should build it using BUILD APK
-
android developer almost 2 yearsThis works, but then of course the app is more limited in terms of developing it... :(