Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI] in Android studio 3.0

As per this blogpost from CommonsWare, AndroidManifest.xml file can have an android:testOnly attribute.

In my AndroidManifest.xml it is set as "false"

android:testOnly="false" 

And I am generating the apk file using the “Build APK(s)” menu option as shown below image,

enter image description here

And when i am trying to install app from command line, adb install -r myapp.apk, I am still getting error,

Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Android studio version is as below, enter image description here

What else shall I do to make my app run?

like image 294
AADProgramming Avatar asked Jan 20 '18 05:01

AADProgramming


2 Answers

You can also use command like this :

adb install -r -t myapp.apk 

it works for me:

PS C:\Users\languoguang> adb -P 12345 install -r D:\GreeneTrans\HelloWorld-signed.apk adb: failed to install D:\GreeneTrans\HelloWorld-signed.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI] PS C:\Users\languoguang> adb -P 12345 install -t D:\GreeneTrans\HelloWorld-signed.apk Success PS C:\Users\languoguang> adb -P 12345 install -r -t D:\GreeneTrans\HelloWorld-signed.apk Success PS C:\Users\languoguang> 
like image 136
Languoguang Avatar answered Sep 19 '22 09:09

Languoguang


Just use the following command:

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

You do not need to use -r, -r means Reinstall an existing app, keeping its data.

Install an app You can use adb to install an APK on an emulator or connected device with the install command:

adb install path_to_apk

You must use the -t option with the install command when you install a test APK. For more information, see -t.

https://developer.android.com/studio/command-line/adb#move

-t: Allow test APKs to be installed. Gradle generates a test APK when you have only run or debugged your app or have used the Android Studio Build > Build APK command. If the APK is built using a developer preview SDK (if the targetSdkVersion is a letter instead of a number), you must include the -t option with the install command if you are installing a test APK.

https://developer.android.com/studio/command-line/adb#-t-option

Or you could use the same command as you click Run in Android Studio

adb push {project dir}/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/{appId}  adb shell pm install -t /data/local/tmp/{appId} 

appId is defined in the app/build.gradle.

defaultConfig {     applicationId appId 

Now the app is installed from locally on the device Launch the first activity.

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

2019-11-13 13:43 Gradle sync started

13:44 Project setup started

13:44 Executing tasks: [:app:generateDebugSources, :vplus_explore:generateDebugSources, :vplus_uibase:generateDebugSources, :vplus_widget:generateDebugSources, :vplus_runtime:generateDebugSources, :vplus_cards:generateDebugSources, :vplus_launcher:generateDebugSources, :vplus_settings:generateDebugSources, :vplus_transactions:generateDebugSources, :vplus_payment:generateDebugSources, :vplus_common:generateDebugSources, :vplus_account:generateDebugSources, :vplus_commonres:generateDebugSources, :vplus_bootstrap:generateDebugSources, :vplus_logger:generateDebugSources]

13:44 Gradle sync finished in 27 s 126 ms

13:44 Gradle build finished in 4 s 666 ms

13:45 * daemon not running; starting now at tcp:5037

13:45 * daemon started successfully

13:45 Executing tasks: [:app:assembleDebug]

13:46 Gradle build finished in 33 s 640 ms

like image 32
Francis Bacon Avatar answered Sep 18 '22 09:09

Francis Bacon