Can anyone help in how to install .apk file in the android device/emulator programmatically?
I have tried the below methods:
UiDevice mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
mDevice.executeShellCommand("adb shell pm install -t -r /data/local/tmp/com.example.xxxxx.xxxxxx");
But it is not working.
I am using UIAutomator for android native app automation testing, I need to install .apk file into android device/emulator before proceeding with my test scripts execution.
executeShellCommand runs inside your device. No need adb shell again.
UiDevice mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
mDevice.executeShellCommand("pm install -t -r /data/local/tmp/com.example.xxxxx.xxxxxx");
You can use the code below to install an application from the command line
adb install example.apk
Before execute `adb shell pm install`, run "adb root" command firstly.
if you rooted the device, this step could be omitted.
Related
I'm running nixos and I have a .apk file, i.e. an Android app.
There is the handy tool adb (Android Debug Bridge) and the command
adb install /path/to/app.apk
How do I get it to work on nixos?
The binary adb is in androidsdk. So either run
nix-env -i androidsdk
or add androidsdk to the list environment.systemPackages in /etc/nixos/configuration.nix.
Your Android phone needs to be plugged in and have USB debugging enabled as documented on developer.android.com.
Simply running adb install ... didn't work for me. Instead I did
sudo adb start-server
adb install /path/to/app.apk
or
adb install /path/to/app.apk -r
for overwriting an already installed app.
I've connected the smarthpone (rooted) to the PC (Linux) with ADB.
Eveything works fine excepts the fact that I can't unistall apps from shell. I've tried :
adb unistall com.mirsoft.passwordmemory
adb unistall -k com.mirsoft.passwordmemory
And I get the help message as return.
I've also tried:
adb shell pm unistall com.mirsoft.passwordmemory
adb shell pm unistall -k com.mirsoft.passwordmemory
Getting as return
Error: unknown command 'unistall'
followed by the help message.
Other commands works fine.
Am I doing something wrong?
uninstall has an n after the i. Use adb uninstall com.mirsoft.passwordmemory.
You can also try to uninstall with the rm command:
adb shell rm com.mirsoft.passwordmemory
Don't forget typically the su command to grant the super user permissions.
I just changed my PC, and now I have a problem with Android Studio, every time i try to run or compile an app it install it correctly, but then it cannot start the main activity of the app, if you need it this is the full Android studio output:
Waiting for device.
Target device: samsung-gt_i9000-3733E37B1ACB00EC
Uploading file
local path: C:\Users\Federico\swagmasta\TurnarioConapo1.0\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/feddycapdev.conapo.turnario
Installing feddycapdev.conapo.turnario
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/feddycapdev.conapo.turnario"
pkg: /data/local/tmp/feddycapdev.conapo.turnario
Launching application: feddycapdev.conapo.turnario/feddycapdev.conapo.turnario.MainActivity.
DEVICE SHELL COMMAND: am start -D -n "feddycapdev.conapo.turnario/feddycapdev.conapo.turnario.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error: Adb refused a command
I tried to manually run am start -D -n "feddycapdev.conapo.turnario/feddycapdev.conapo.turnario.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER from the adb shell, and it work correctly, some ideas on how could i fix it?
UPDATE : I tried running as admin, rebooting PC, reconnecting cable, killing all the adb.exe processes, killing the adb server and restarting it, noone of this worked.
Maybe it's a problem of driver? I'm using a Samsung Galaxy S for debugging, at the beginning the PC didn't recognized it, so I installed samsung USB driver, so maybe that's the real problem, but if i can install app to my device via adb the driver should be working right?
Please kill and start adb server from console or terminal using following commands:
adb kill-server
adb start-server
If it does not help try to restart your computer.
If you are getting
adb command not found
error then you have to go in platform-tools directory in Android SDK.
hope it helps!
It could be blocked by some other instance of adb.
Look into your task manager if you are not running another instance of adb.
What's the difference between installing an app using the install command and using the package manager's pm install command? Do they do the exact same job? Does one command actually call the other in the back?
adb install -r APK_FILE
adb shell pm install APK_FILE
adb install is a command to run from a development host, which uploads a package somewhere temporary and then installs it.
pm install is a command to run locally on the device.
adb does indeed utilize the pm program on the device - see the source code at
https://android.googlesource.com/platform/system/core/+/kitkat-mr2.2-release/adb/commandline.c
I would like to compile and run Android UI black-box tests using only command-line tools on Windows. I wrote an UiAutomatorTestCase, built it, and uploaded it into /data/local/tmp/. I verified that the jar file was copied into the latter directory.
If I type
adb shell
and then type
uiautomator runtest MyTest.jar –c com.example.MyTest
at the adb shell prompt, the test runs successfully. So far so good.
The problem is if I combine these two steps and type
adb shell uiautomator runtest MyTest.jar –c com.example.MyTest
then I get the following error:
Error: /data/local/tmp/ľc does not exist
According to the documentation, this should work. The error is the same on Windows 7 Pro 32-bit HUN and on Windows 8.1 Pro 64-bit ENG. The device is a Samsung Galaxy S3 Mini (GT-I8190), running Android 4.1.2 (API level 16).
What am I doing wrong?
I strongly suppose,
adb shell
$ <command> is same as adb shell <command>. I've never encountered any discrepancy in this regards.
Please try adb kill-server and adb start-server
Please also try adb -s <device_id> shell <command> you can find <device_id> from adb devices
Can you also please let us know what is the output of adb version?