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]
@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