Skip to content

Instantly share code, notes, and snippets.

@xujiaao
Last active May 16, 2024 16:16
Show Gist options
  • Save xujiaao/5fd127a72979cdc3c70dcc1324786f87 to your computer and use it in GitHub Desktop.
Save xujiaao/5fd127a72979cdc3c70dcc1324786f87 to your computer and use it in GitHub Desktop.
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]
@alex-amenos
Copy link

Thanks!!!! :-)

@Daniel587
Copy link

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
Copy link
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
Copy link

tyzero commented Mar 10, 2018

save my day, thanks

@395305838
Copy link

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

@Tan-Tshunglee
Copy link

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
Copy link

thanks!

@danirb
Copy link

danirb commented May 24, 2018

Thanks!

@xujiaao
Copy link
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
Copy link

"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
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
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