android studio install error [INSTALL_FAILED_INVALID_APK] - android

I am getting this:
01/20 17:14:40: Launching MyLuaGame $ adb push /Users/name/Desktop/MyLuaGame/frameworks/runtime-src/proj.android-studio/app/build/outputs/apk/MyLuaGame-debug.apk /data/local/tmp/myTest
$ adb shell pm install -r "/data/local/tmp/myTest" Please select on your phone whether can install the app by The ADB command?
pkg: /data/local/tmp/myTest Failure [INSTALL_FAILED_INVALID_APK]
$ adb shell pm uninstall myTest DELETE_FAILED_INTERNAL_ERROR
Error while Installing APK

You have to execute a release apk for installation in device. You can connect your device in android studio and get the debug version app but in order to get an apk to install other devices, you must execute release version apk using a keystore

A common reason for this error is having an app with the same package name already installed but with a different certificate e.g. a store release or a development build from another machine.
Try uninstalling the package with ADB first, using adb uninstall YOUR_PACKAGE_NAME

Related

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,
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,
What else shall I do to make my app run?
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>
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
If you really want to be able to remove the test flag from the APK generated in Android Studio, you could try adding the following to your gradle.properties file:
android.injected.testOnly = false
Solution 1
Click drop-down menu with your configuration and choose Edit Configurations…
Select tab General and add -t to Install Flags field. Click Ok.
Now start the application again and it should work.
Solution 2
This means that, the shared application has some test packages, so
unless those has been removed and source is recompiled, you will not
be able to install this apk. But adb command provides a flag “-t”
using which you can install the apps with test packages.
$ adb install -r -t YourAndroidApp.apk
2566 KB/s (7266004 bytes in 2.764s)
Success
Solution 3
This error might occur if you moved the project from other computer where it was stored in different directory. To resolve the problem: Clean the project and build it again.
Solution 4
Go to “Settings” -> “Build, execution, deployment” and disable “instant run to hot swap code…”
Solution 5
Add this line to gradle.properties:
android.injected.testOnly = false
If you would like to manually install an APK or give it to someone for manual installation using the following adb command, then you should only build the APK from the Menu bar -> Build -> Build Bundle/APK.
adb install -r xyz.apk
Do not click on the play button as it builds the APK for test purposes only. Clicking on the play button overrides the APK in the default location which can then be installed manually by using the following command only.
adb install -r -t xyz.apk

Getting an error when Android apk is tried to deploy external device

Launching app
$ adb push /app/build/outputs/apk/prelollipop/debug/XXX.apk /data/local/tmp/XXX.android
$ adb shell pm install -t -r "/data/local/tmp/XXX.android"
Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/XXX.android-1: Package /data/app/com.ozan.android-1/base.apk code is missing]
$ adb shell pm uninstall XXX.android
Unknown failure (at android.os.Binder.execTransact(Binder.java:573))
Error while Installing APK
I am getting this error when i try to deploy app to external device after codes successfully build on Android Studio 3.0.
Also i use Dexguard v8.1.01. However if i build the apk with dexguard .apk is successfully deploy the device. the problem is occured without dexguard build.
Any idea to fix it?

react-native run-android mismatch version adb server version

I recently install react-native, initialize a project and run it
$ react-native init AwesomeProject
$ react-native run-android
Always get a error
adb server version (32) doesn't match this client (36); killing...
and my device shows me
How to solve both error?
This is because the adb version on your system is different from the adb version on the android sdk platform-tools. you can check that to insure:
Open the terminal and check the adb version on the system:
$adb version
And from the Android SDK platform-tool directory:
$cd ~/Android/Sdk/platform-tools
$./adb version
simple solution:
Copy adb from Android SDK directory to usr/bin directory.
$sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin
Did you brew install android-sdk?
I was getting the following error when running react-native run-android:
adb server version (36) doesn't match this client (39); killing...
error: could not install *smartsocket* listener: Address already in use
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
Could not run adb reverse: Command failed: /Users/beau/Library/Android/sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
I found that I had adb installed at /usr/local/bin/adb:
$ ll /usr/local/bin/adb
lrwxr-xr-x 1 beau admin 38 Mar 13 12:12 /usr/local/bin/adb# -> ../Cellar/android-sdk/24.4.1_1/bin/adb
It was installed with brew install android-sdk and never used, so I uninstalled it:
brew uninstall android-sdk
…and the adb error was gone when I re-ran react-native run-android.
Thanks , this solution works for me. I have been struggling with this problem for few days, reinstall android studio, add custom android Sdk tools path under Genymotion ADB setting nothing works.Just wants to share with who have the same issues.
I use Ubuntu 16.04. I did the copy adb to /usr/bin as suggested, since the adb version I have is 1.0.32.
/usr/local$ adb version
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
Installed as /usr/bin/adb
Then I updated ADB setting under Genymotion to the default, use Genymotion Android tools. And start virtual device.
Under Expo XDE, start the project, then click device. Then I see the following message.
Couldn't adb reverse: closed
Opening on Android device
Building JavaScript bundle: finished in 3669ms.
It works!!!

Android emulator not installed app

Installation failed since the device possibly has stale dexed jars that don't match the current version (dexopt error). In order to proceed, you have to uninstall the existing application.
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.tell_it_dell.myapplication1"
pkg: /data/local/tmp/com.example.tell_it_dell.myapplication1
Failure [INSTALL_FAILED_DEXOPT]
DEVICE SHELL COMMAND: pm uninstall com.example.tell_it_dell.myapplication1
DELETE_FAILED_INTERNAL_ERROR
How do I solve this?
What I did to fix it, is to open gradlew via cmd, and write "gradlew clean" on the project. Then pressed play button and it worked again.

Install an apk file from command prompt?

I want to install a file using the Windows command line. First I want to build after compiling all the .jar files to create an .apk file for an Android application without using Eclipse.
Does anyone know how this can be done without the use of Eclipse & only by making use of command line.
You can use the code below to install application from command line
adb install example.apk
this apk is installed in the internal memory of current opened emulator.
adb install -s example.apk
this apk is installed in the sd-card of current opened emulator.
You can also install an apk to specific device in connected device list to the adb.
adb -s emulator-5554 install myapp.apk
Refer also to adb help for other options.
You can build on the command line with ant. See this guide.
Then, you can install it by using adb on the command line.
adb install -r MyApp.apk
The -r flag is to replace the existing application.
Use the Android Debug Bridge command line tool adb eg: adb install filename.apk.
A good reference for adb is Here
install [options] <PATH> Installs a package (specified by <PATH>) to the system.
Options:
-l: Install the package with forward lock.
-r: Reinstall an exisiting app, keeping its data.
-t: Allow test APKs to be installed.
-i <INSTALLER_PACKAGE_NAME>: Specify the installer package name.
-s: Install package on the shared mass storage (such as sdcard).
-f: Install package on the internal system memory.
-d: Allow version code downgrade.
uninstall [options] <PACKAGE> Removes a package from the system.
Options:
-k: Keep the data and cache directories around after package removal.
You can install an apk to a specific device/emulator by entering the device/emulator identifier before the keyword 'install' and then the path to the apk. Note that the -s switch, if any, after the 'install' keyword signifies installing to the sd card. Example:
adb -s emulator-5554 install myapp.apk
The simple way to do that is by command
adb install example.apk
and if you want to target connect device you can add parameter " -d "
adb install -d example.apk
if you have more than one device/emulator connected you will get this error
adb: error: connect failed: more than one device/emulator
- waiting for device - error: more than one device/emulator
to avoid that you can list all devices by below command
adb devices
you will get results like below
C:\Windows\System32>adb devices
List of devices attached
a3b09hh3e device
emulator-5334 device
chose one of these devices and add parameter to adb command as " -s a3b09hh3e " as below
adb -s a3b09a6e install example.apk
also as a hint if the path of the apk long and have a spaces, just add it between double quotes like
adb -s a3b09a6e install "c:\my apk location\here 123\example.apk"
Commands for install APK files like it does in Android Studio you can see below.
1) To push your app:
adb push /pathOfApk/com.my.awesome.apk /data/local/tmp/com.my.awesome
where com.my.awesome is your package.
2) To install:
adb shell pm install -t -r "/data/local/tmp/com.my.awesome"
Open Terminal in Android Studio
You might see
C:\Users\nikhil\AppData\Local\Android\Sdk\platform-tools>
copy and paste your apk which you want to install on above path inside platform-tools.
In my case app-qa-debug.apk I kept inside platform-tools folder.
install command
adb install app-qa-debug.apk
so in the terminal you could see something
C:\Users\nikhil\AppData\Local\Android\Sdk\platform-tools>adb install app-qa-debug.apk
post-installation you could get the message as
Performing Streamed
Install Success
Press Win+R > cmd
Navigate to platform-tools\ in the android-sdk windows folder
Type adb
now follow the steps writte by Mohit Kanada (ensure that you mention the entire path of the .apk file for eg. d:\android-apps\test.apk)
It is so easy!
for example my apk file location is: d:\myapp.apk
run cmd
navigate to "platform-tools" folder(in the sdk folder)
start your emulator device(let's say its name is 5556:MyDevice)
type this code in the cmd:
adb -s emulator-5556 install d:\myapp.apk
Wait for a while and it's DONE!!
You're likely here because you want to build it too!
Build
gradlew
(On Windows gradlew.bat)
Then Install
adb install -r exampleApp.apk
(The -r makes it replace the existing copy, add an -s if installing on an emulator)
Bonus
I set up an alias in my ~/.bash_profile
alias bi="gradlew && adb install -r exampleApp.apk"
(Short for Build and Install)
To install a debug (test) apk, use -t:
Run Build-Make Project
Look for the last generated apk in the app folder.
Example:
adb install -t C:\code\BackupRestore\app\build\outputs\apk\debug\app-debug.apk
You can do this by using adb command line tools OR gradle commands:
See this Guide.
Setup command line adb
export PATH=/Users/mayurik/Library/Android/sdk/platform-tools/adb:/Users/mayurik/Library/Android/sdk/tool
Gradle commands to build and install.
#Start Build Process
echo "\n\n\nStarting"
./gradlew clean
./gradlew build
./gradlew assembleDebug
#Install APK on device / emulator
echo "installDebug...\n"
./gradlew installDebug
You can also uninstall any previous versions using
`./gradlew uninstallDebug`
You can launch your main activity on device/emulator like below
#Launch Main Activity
adb shell am start -n "com.sample.androidbuildautomationsample/com.sample.androidbuildautomationsample.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
I use this script on my windows machine ( insall all apks in current folder to all available devices )
Write-Host "Listing APKs..."
$List_Apks = New-Object System.Collections.ArrayList
Get-ChildItem -Path .\ -Filter *.apk -File -Name| ForEach-Object {
$apk_filename = [System.IO.Path]::GetFileName($_)
$List_Apks+=$apk_filename
$apk_filename
}
Write-Host "Found apks "$List_Apks.Length
Write-Host ""
$raw_list = adb devices
$array_lines = $raw_list.Split("\n")
Write-Host "Listing devices "
$List_Device_Ids = New-Object System.Collections.ArrayList
1..($array_lines.Length-2) | foreach {
$device_id = $array_lines[$_].Split([char]0x9)[0]
$List_Device_Ids+=$device_id
$device_id
}
Write-Host "Found devices "$List_Device_Ids.Length
0..($List_Device_Ids.Length-1) | foreach {
$device_id = $List_Device_Ids[$_]
0..($List_Apks.Length-1) | foreach {
$apk_file_name = $List_Apks[$_]
Write-Host "Installing " $apk_file_name "->" $device_id
adb -s $device_id install -r $apk_file_name
}
}
Write-Host "Endo"
Save this as install-apks.ps1
Then from the powershell :
powershell -executionpolicy bypass -File .\install-apks.ps1
For people who wants to load apk from Linux system with React native application running on it.
I have given the path in which the android application resides as well. So that those who need to find the apk file can go to view it.
adb -s 434eeads install android/app/build/outputs/apk/debug/app-debug.apk
For reinstalling the android app on phone
adb -s 434eeads install -r android/app/build/outputs/apk/debug/app-debug.apk
-s -> source/serialNumber
r -> Re-install
path + file name : android/app/build/outputs/apk/debug/app-debug.apk
It is for react native applications.

Categories

Resources