adb and multiple device simultaneously - android

I am automating some test on android devices.
I am using Jenkins in order to run the tests (via jobs)
each job runs with a 95% success rate when only 1 device is connected to the machine
but when I plug 2 android devices or more, it seems adb has some trouble and I get a 5% success rate.
is it ok to run multiple instances of adb command?
here is the command I run for each job:
adb -s DEVICESERIAL shell am force-stop com.myapp.test
adb -s DEVICESERIAL shell am force-stop com.myapp
adb -s DEVICESERIAL uninstall com.myapp adb -s DEVICESERIAL uninstall com.myapp.test
adb -s DEVICESERIAL install -r com.myapp adb -s DEVICESERIAL install -r com.myapp.test
adb -s DEVICESERIAL shell am instrument -w TESTNAME/android.test.InstrumentationTestRunner
adb -s DEVICESERIAL logcat -d -v time
all command run with success but when the test starts and when I have multiple devices connected i get errors like for example:
- Unable to find instrumentation target package
- INSTRUMENTATION_STATUS_CODE: 0
- Failure [INSTALL_FAILED_INVALID_URI]
at first I thought the test apk was not installed correctly, but when trying manually after the failure, it worked fine (so the test file is installed)
again. Using 1 device only, everything is stable.
Is there something special to do in order to install and run the test on different devices simultaneously?
note that I have tried different usb ports, different cables etc...
thanks

Related

Is there any command for installing an app in Genymotion?

Hey guise I want to install an app on several devices in Genymotion by using terminal in ubuntu. Each time I do this:
adb install package.app
It gives me the below error:
error: more than one device/emulator
- waiting for device -
error: more than one device/emulator
I also read about
adb -s udid uninstall package.app
but this is not the solve I want. I don't want to use udid and also I don't know which device has my app from before?
Any suggestions?!
adb help is not extremely clear on what to do:
-d - directs command to the only connected USB device...
-e - directs command to the only running emulator...
-s <serial number> ...
-p <product name or path> ...
The flag you decide to use has to come before the actual adb command:
adb -e install path/to/app.apk
You cannot pass adb commands when there are more than one device connected and running at the same time ; this is a limitation with adb.
Wow finally!
I found this command as my answer:
adb devices | awk 'NR>1{print $1}' | xargs -n1 -I% adb -s % install app.apk
Thanks to sivze

"Device is offline" after succesfully installing APK

When trying to debug my app, the installation of the APK works fine, but starting the debugger, gives the error "Device is offline":
01/17 15:56:08: Launching app
$ adb push /home/bf/Projects/.../app-full-debug.apk /data/local/tmp/nl.my.app
$ adb shell pm install -t -r "/data/local/tmp/nl.my.app"
Success
APK installed in 3 s 918 ms
$ adb shell am start -n "nl.my.app/nl.my.app.activities.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Device is offline
I tried updating the SDK, to no avail. Running the same app on another device works fine.
Also, when launching (in the "Select Deployment Target" screen), it doesn't give me any information, only serial number and [null], while I get full info on other devices (make and model, etc)
I didn't resolve the issue itself, but using TCP/IP debugging did work:
~$ adb tcpip 5555
~$ adb connect <ipaddr>:5555
the device is now shown with all information in the "Select Deployment Target" screen as well.

Check if headless android emulator is running

I am running a headless emulator (Android api 25) on a Ubuntu linux 14 server and I see the below output for the command-
$./adb devices
List of devices attached
emulator-5556 device
However, If i try to run any other command I get error
$./adb shell dumpsys deviceidle get deep
Can't find service: deviceidle
$./adb shell 'pm list packages -f'
Error: Could not access the Package Manager. Is the system running?
How can i verify that my emulator is functional?
is adb devices -l not working? it should show you the status of the device as well
try adb push, for eg
adb push foo.txt /sdcard/foo.txt
or adb install for eg
adb -s emulator-5556 install apkname.apk
these commands will work with any running emulator/device
all these commands are available on the documentation

Adb Shell dumpheap for native not working

I need to take the native dump of the android process.
The cmd I am using is:
adb shell am dumpheap -n <pid> /data/local/tmp/dump.txt
The device is S8, Oreo OS.
Everytime I run this cmd, the 'dump.txt' is generated with the following content:
Native heap dump not available. To enable, run these commands
(requires root):$ adb shell setprop libc.debug.malloc 1 $ adb shell
stop $ adb shell start
Though I am doing it says and the phone is also rooted but it still gives the same content.
I am stuck. Any help would be appreciated.

Testing multiple Android phones connected to one PC

I am about to develop a test program for mobile phones.
To reduce cost, I want multiple Android phones to one PC, then install test program to the phones and then run the test program at once.
Can it be done? I am using Android SDK and NDK. Phones are not rooted.
Sure.
You can write a simple shell wrapper to run your tests on all connected devices simultaneously - remember their serial-numbers and use this snippet:
$ adb -s serial1 install <your_test_package>.apk
$ adb -s serial2 install <your_test_package>.apk
$ adb -s serial1 shell am instrument -w <your_test_package_name>/<runner_class>
$ adb -s serial2 shell am instrument -w <your_test_package_name>/<runner_class>
For details, consult with
http://developer.android.com/tools/help/adb.html#directingcommands
http://developer.android.com/tools/testing/testing_otheride.html#RunTestsCommand
Also, you can run your tests on any combination of physical devices, AVDs and virtualized Android-x86 installations (using KVM or VirtualBox).

Categories

Resources