Rearrange list in ADB DEVICES - android

When I type "adb devices", it will list:
emulator-5554 device <-- this is emulator
0123456789ABCDEF device <-- this is my smartphone
A software called ShareKM will automatically detect the first device in the list thus will cause an error "Android app is not installed".
So what I did is, close the emulator, adb kill-server, adb start-server, launch ShareKM, launch emulator. If I "adb devices" it will be:
0123456789ABCDEF device <-- this is my smartphone
emulator-5554 device <-- this is emulator
But this is too hustle.
Is there a command to rearrange the list without killing or restart emulator? Lets say "adb put 0123456789ABCDEF to 1"

Related

When to use adb connect with localhost?

I have one emulator set up locally
$ adb devices
List of devices attached
emulator-5554 device
When I do adb connect localhost:5555 I will have 2 devices set up
$ adb devices
List of devices attached
emulator-5554 device
localhost:5555 device
How is that possible? This is still the same device, right? Available only under two different names.
In what situations running adb connect localhost:5555 make sense? I've seen plenty of posts on SO doing that, but what they have emulator available locally?

How do I adb disconnect an emulator and keep it disconnected?

I have somehow gotten a couple of Android emulators connected via ADB and I can't get rid of them.
> adb devices -l
List of devices attached
emulator-5554 device product:sdk_gphone_x86 model:sdk_gphone_x86 device:generic_x86_arm transport_id:1
emulator-5556 device product:sdk_gphone_x86 model:sdk_gphone_x86 device:generic_x86_arm transport_id:2
When I adb disconnect it disconnects everything, but they come back almost instantly (with an incremented transport_id)
When I adb kill-server and then adb devices -l it restarts the adb server (as expected) and reconnects the emulators. I understand that it scans the even ports from 5554 : https://developer.android.com/studio/command-line/adb#howadbworks
When I run the emulator list devices they don't appear:
> .\emulator.exe -list-avds
Nexus_5_API_30
Pixel_2_API_29_x86_64
Pixel_4a_API_30
Tablet_API_30
I don't think I've got another Android SDK Emulator suite installed locally.
The correct way of killing an emulator would be:
adb -s emulator-5554 emu kill
I managed to find the process that was running the emulators:
On windows, using Powershell:
> Get-Process -Id (Get-NetTCPConnection -LocalPort 5554).OwningProcess
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
134 4,074.23 1,998.07 2,544.47 12528 1 qemu-system-x86_64-headless
And killing that using the process manager did the trick.

ADB more than one device/emulator but there isn't

(master) $ adb -s emulator-5554 reverse tcp:8081 tcp:8081
error: more than one device/emulator
(master) $ adb devices -l
List of devices attached
emulator-5554 device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:2
Trying to deploy a react-native app to an emulated device. The build, gradle etc runs fine but when trying to connect to the emulator it shows an error more than one device/emulator despite there only being one device when running adb devices
Literally no idea how to solve this, Android Studio 3.1, emulated device is a Nexus 5x running Android 8. Have restarted, upgraded etc but still get this message.

Detecting if emulator has started completely

I want to check if all the emulators has booted successfully. I have tried with this command adb shell getprop sys.boot_completed this works if i am running one emulator. But if i have more than one emulator this command returns error as following: error: more than one device/emulator.How to solve this?
You should specify the device serial number on the adb command line to let it know which one you want to interact with.
Something like
adb -s emulator-5554 shell ...
Also, if you are doing it from the command line, multiple times and you are starting to be annoyed by that, you can try https://gist.github.com/dtmilano/4537110 which allows you to select the device
$ adb shell
1) 02783201431feeee device 3) emulator-5554
2) 3832380FA5F30000 device 4) emulator-5556
Select the device to use, <Q> to quit: 1
$

running multiple android emulators

I have more than one android emulator running, along with devices connected to the same machine.
I want to to know how to connect to a single emulator/device from the command prompt.
For example: adb shell emulator-5554
But that doesn't work.
You should use -s switch:
adb -s emulator-5554 shell
with the command
adb devices
you get a list of all connected devices like:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device
Then you can run all commands normally, but you have to attach the -s option
e.g.
adb -s emulator-5556 install helloWorld.apk
Take a look at the tutorial if you want to know more about adb.
adb connect xx.xx.xx.xx
adb disconnect xx.xx.xx.xx
it can be X86 Emulators ;)
http://blog.gokifu.com/2011/05/android-x86-faster-emulator/

Categories

Resources