Check if headless android emulator is running - android

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

Related

"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.

Some ADB shell commands only work via ADB and not in terminal emulator

Not a duplicate question or at least I couldn't find anything about this
So I've been getting into ADB and the ADB shell but I don't always have access to a PC so I got a terminal emulator from the play store and some commands don't work via ADB shell
Example: dumpsys battery
Output: can't find service: battery
The command works in ADB shell but not in their terminal emulator. Other dumpsys services work
Why is this?

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.

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/

How do you connect your terminal with the Android emulator

I have tried the navigate to the android tool folder and entering the "adb shell" command but it doesn't seem to work. My terminal seems only to recognize the adb part of the command and gives me an error message. What am I doing wrong???
List all connected devices by typing adb devices
Check, if there are any devices listed. If not you may want to check that your device is connected and/or your emulator is running.
If it works and you have for example your emulator running and your usb-device connected use:
adb shell if you only have device connected.
adb -d shell to connect to an USB-Device.
adb -e shell to connect to an emulated device.
If you have more than one emulator or usb devices you might want to use:
adb -s <DEVICE> shell
Note:
Make sure that the path to the android-sdk is properly set-up in your environment. To quickcheck, fire up a shell and type adb version. If that command succeeds, you're set up. If not, add /path/to/android-sdk/tools and /path/to/android/platform-tools to your $PATH env variable. On windows the android sdk is typically located in C:\Users\<username>\AppData\Local\Android\sdk.

Categories

Resources