getting Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI] in Android studio 3.0 –

Development issue/problem:

According to this CommonsWare blog, the androidManifest.xml file can have the attribute android:testOnly.

In my AndroidManifest.xml it is defined as false.

android: testOnly=false

And I generate the apk file using the Build APK(s) menu option as shown in the picture below,

And if I try to install the application from the command line, install adb -r myapp.apk, I always get an error,

The version of Android Studio is shown below,

What else can I do to make my application work?

How can I solve this problem?

Solution 1:

If you really want to be able to remove the test flag from the MOT generated in Android Studio, you can try adding the following to your :

android.injection.testOnly = false

Solution 2:

You can also use the command:

adb -r -t install myapp.apk

It works for me:

PS C: Userslanguoguang> install adb -P 12345 -r D: GreeneTransHelloWorld-signed.apk
adb : The installation of D:GreeneTransHelloWorld-signed.apk failed: Failed [INSTALL_FAILED_TEST_ONLY : installPackageLI]
PS C:Userslanguoguang> adb -P 12345 install -t D:GreeneTransHelloWorld-signed.apk
PS C:Userslanguoguang> adb -P 12345 install -r -t D:GreeneTransHelloWorld-signed.apk
PS C:Userslanguoguang>.

Solution 3:

Just use the following command:

install adb -t app/build/outputs/apk/debug/app-debug.apk

You do not need to use -r, -r to reinstall an existing application by backing up the data.

Installing the application You can use adb to install the APK on the emulator or on a
device connected to the installation command:
adb install path_to_apk
You must use the -t option with the installation command when installing the APK
test. For more information, see -t.

-t : Allows the installation of test APKs. Gradle generates a test APK if you have just launched or debugged the application or if you have used the Android Studio
Build > Build APK command. If the APK was created using Developer Preview SDK (if targetSdkVersion is a letter and not a number), you will need to include the -t option in the installation command when installing the test APK.

You can also use the same command as when you click the Run button in Android Studio.

adb push {project directory}/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/{appId}

install adb shell pm -t /data/local/tmp/{appId}

appId is defined in app/build.gradle.

defaultConfig {
applicationId appId

The application is now installed locally on device
Perform the first action.

adb shell at start -n {package name}/{package name}.splash.SplashActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

2019-11-13 13:43 Start synchronizing timeline
13:44 Start configuring project
13:44 Start executing tasks: [:app:generatedDebugSources,
13:44 Sync completed in 27s 126ms
13:44 Assembly completed in 4s 666ms
13:45 * daemon not running; from tcp:5037
13:45 * daemon successfully started
13:45 Run the task: [:app:assemblyDebug]
13:46 Assembly completed in 33s 640ms.

Solution 4:

Solution 1

Click on the drop-down menu with your configuration and select Change Configuration.

Changing configurations...

Select the General tab and add -t in the Set Fields field. Click OK.

plant flags

Now restart the application and it should work.

Solution 2

This means that certain tests are included in the general application. Until they have been removed and the source code has been recompiled, you cannot install this apk. However, the adb command gives the -t
flag which makes it possible to install applications with test packages.

Adb install -r -t YourAndroidApp.apk2566 KB/s (7266004 bytes in 2,764s) successful

Solution 3

This error may occur if you move the project from another computer where it is stored in another folder. To solve the problem: Clean it up and rebuild it.

Solution 4

Go to Settings -> Build, Execute, Implement and Immediately Execute at hotswapcode….. deactivate

Solution 5
Add this line to :

android.injection.testOnly = false

Good luck!

Related Tags:

Leave a comment

Your email address will not be published. Required fields are marked *