Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable 'testOnly' mode for Android Studio 3.0
tags
Android
Android Studio

Disable 'testOnly' mode for Android Studio 3.0

Android Studio 3.0 sets android:testOnly="true" automatically on APKs that are ran from the IDE.

However, for some devices (such as OPPO R11), the test-only APKs can never be installed ...

If you face the same problem, try add this line to your '/gradle.properties':

# gradle.properties
android.injected.testOnly=false

Then the boring android:testOnly attribute disappears. ( ͡° ͜ʖ ͡°)✧


BTW, if you do not have an 'OPPO R11' (congratulations), and just want to install such a test-only app with adb, try:

adb install -t <test_only_apk_filename>.apk

Otherwise, you will get a failure message:

Failed to install app-debug.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
@farwayer

This comment has been minimized.

Copy link

farwayer commented Dec 20, 2017

Thanks!

@edwardZj

This comment has been minimized.

Copy link

edwardZj commented Jan 5, 2018

I have the same proplem on MOTO Z Play.
You solve my problem!
Thanks very much!!!!!!

@Pinned

This comment has been minimized.

Copy link

Pinned commented Jan 15, 2018

Thanks.

@zchtcl

This comment has been minimized.

Copy link

zchtcl commented Jan 15, 2018

感谢楼主

@loniecc

This comment has been minimized.

Copy link

loniecc commented Jan 17, 2018

THX

@liangzai-cool

This comment has been minimized.

Copy link

liangzai-cool commented Jan 17, 2018

👍

@alex-amenos

This comment has been minimized.

Copy link

alex-amenos commented Jan 24, 2018

Thanks!!!! :-)

@Daniel587

This comment has been minimized.

Copy link

Daniel587 commented Feb 20, 2018

Hi, I'm having this problem and I don't don't understand, what do you mean by:

"add this line to your '/gradle.properties' "

Where is it? I don't see any file by that name, I have 2:

"build.gradle" files,

and "settings.gradle", and "gradle-wrapper.properties".

But no file with the name that you wrote.

Where is it?

@xujiaao

This comment has been minimized.

Copy link
Owner Author

xujiaao commented Feb 21, 2018

@Daniel587 AndroidStudio will automatically create 'gradle.properties' when you create a project... if you can not find it, just create it in your project dir.

@tyzero

This comment has been minimized.

Copy link

tyzero commented Mar 10, 2018

save my day, thanks

@395305838

This comment has been minimized.

Copy link

395305838 commented Mar 20, 2018

THX!!!!!!!!!!
THX!!!!!!!!!!
THX!!!!!!!!!!
THX!!!!!!!!!!
THX!!!!!!!!!!
THX!!!!!!!!!!

@Tan-Tshunglee

This comment has been minimized.

Copy link

Tan-Tshunglee commented Mar 29, 2018

This is a android feature. When apk manifest file application tag has testOnly=true setting.
The system block the installation of apk, except that installation is through adb with -t option.

@crispert

This comment has been minimized.

Copy link

crispert commented Mar 30, 2018

thanks!

@danirb

This comment has been minimized.

Copy link

danirb commented May 24, 2018

Thanks!

@xujiaao

This comment has been minimized.

Copy link
Owner Author

xujiaao commented Jun 5, 2018

@Tan-Tshunglee

You are right... But some manufacturer changes the default behavior (e.g. OPPO...), on my OPPO R11 phone adb install -t dose not work...

@encoderlee

This comment has been minimized.

Copy link

encoderlee commented Jul 20, 2018

"adb install -t " is invalid for some manufacturers' phones, like oppo /Lenovo, they always show INSTALL_FAILED_TEST_ONLY even though you've already use "-t"

@anilsakr

This comment has been minimized.

Copy link

anilsakr commented May 8, 2019

It worked for me. Try to run this and build again. ./gradlew assembleRelease

Maybe You are uploading the wrong apk file which is generated previously not the signed apk. So select the apk file by locating the exact path of the generated signed apk file.

@Mayoogh

This comment has been minimized.

Copy link

Mayoogh commented Sep 7, 2019

Problem
App not installed shows when installing signed apk. The Application will install without any problem for the first time, later if I uninstall and try to reinstall the same apk it shows App not installed

Tried the following things

  • Tried only with V1 signature
  • Tried only with V2 signature
  • Tried with both with V1 and V2 signature
  • Changed Build Variant to Release
  • Tried on 3 different devices
  • Uninstalled previous version from the device(for all users) and release folder
  • Removed cache memory of the smartphone.

Note :
I had error a while creating keystore Key was created with errors: Picked up _JAVA_OPTIONS: -Xmx512M last week but this was solved. But it was resolved by deleting _JAVA_OPTIONS from environment variables I think after this the started.

No Problem with codes
I am 100% sure that it's not a problem in the code Because of I tried making signed apk for the basic login activity application. didn't change a single line of code. But the result was same

Tried the following thread
How to fix App not installed error in Android
How to Fix Android App Not Installed Error?
App not installed
Is there any way to fix APP not installed? (Exact same issue)
None of them solved the issue

Temporary fix
The only method working was disabling Google Play Protect (which is not a proper fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.