when I execute command line: dumpsys meminfo
in my android shell enviroment (Android 8.1)
I got the output: * SERVICE 'meminfo' DUMP TIMEOUT (10s) EXPIRED *
Does Anyone can tell me how to avoid the issue without rebooting the device?
Because I am developing a function that monitor the memories of all processes when the device is running
Henry.Woo says is right.
use:
adb shell dumpsys -t 60 meminfo
Related
I am calling a sequence of adb commands as below
"adb root"
adbd is already running as root
"adb wait-for-device"
"adb shell getprop sys.boot_completed"
1
boot_completed successful
"adb remount"
remount succeeded
"adb uninstall ..."
Success
"adb shell rm -rf ..."
"adb push ..."
9366 KB/s (46299481 bytes in 4.827s)
"adb push ..."
14 files pushed. 0 files skipped.
9701 KB/s (26658580 bytes in 2.683s)
"adb push ..."
14 files pushed. 0 files skipped.
9544 KB/s (33592272 bytes in 3.437s)
"adb reboot"
"adb wait-for-device"
"adb root"
error: protocol fault (no status)
error: protocol fault (no status)
Sleeping 2 sec. before retrying
increasing timeout by 180.0 seconds
"adb root"
error: device not found
error: device not found
Sleeping 2 sec. before retrying
increasing timeout by 270.0 seconds
"adb root"
error: device not found
error: device not found
Sleeping 2 sec. before retrying
increasing timeout by 405.0 seconds
"adb root"
error: device not found
error: device not found
But as you can see the android device starts throwing error of 'device not found' at last. I have come to know that "adb reboot" might be the culprit here as reboot might not have finished booting completely before next commands starts executing. To check this I have used "adb wait-for-device". But it seems that it is not able to detect device state correctly.
I also have found the use of "adb shell getprop sys.boot_completed" to rectify this error.
Detect when Android emulator is fully booted
I am not sure though when to use "adb shell getprop sys.boot_completed". Is it to be used on every reboot of the device or can I use it after every "adb wait-for-device" command ?
You should call getprop sys.boot_completed after boot or reboot and together with adb wait-for-device like this:
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
When you call just single adb wait-for-device it doesn't guarantee that boot is completed since it only check that daemon has started properly.
I try to develop script to launch armeabi-v7a emulator and execute gradle connectedAndroidTest task to run android device tests targeted to my app.
I wrote script which successfully check required emulator target and download and install it if it is missed and then launch emulator. All these points work well. But After I launch emulator I have to wait until it will be completely booted.
I guess my problem is that I cannot rightful detect that emulator was completely finish his boot operation and is ready to install apps as well.
According to suggestions in web we can use two following system properties to detect complete boot, it is
init.svc.bootanim - state of boot animation
sys.boot_completed - system state of boot operation
We can revise them by calling
adb -e shell getprop init.svc.bootanim and adb -e shell getprop init.svc.bootanim accordingly
I figured out that sys.boot_completed more reliable than init.svc.bootanim, but anyway I wait both of them. But it does not help, because if after waiting device boot I start connectedAndroidTest task after running about 4 minutes it fails with next exception
Unable to install /Users/busylee/temp/TestRun/app/build/outputs/apk/debug/app-debug.apk
com.android.ddmlib.InstallException
at com.android.ddmlib.Device.installRemotePackage(Device.java:1011)
at com.android.ddmlib.Device.installPackage(Device.java:911)
...
Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:557)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:383)
...
But if I wait for a while it completes. Which I guess means that I do not wait something before install test app.
Do you have any ideas what I can rely on while waiting an emulator start?
I started an Android emulator using the following shell command:
emulator -avd TEST_AVD
The emulator starts just fine, but the shell script never finishes executing. It just hangs there even after the emulator has completed startup. I have tried with a number of other arguments that I could find, but nothing could quite do what I want it to. How do I know, or stop the shell command, when the emulator is ready to go?
I am setting up our Jenkins CI to use a Jenkinsfile to start the emulator, and then run a series of gradle commands. In short, I'd like to do this:
sh "emulator -avd TEST_AVD"
sh "./gradlew clean test spoon"
However, I don't want to run the gradle tasks until the emulator has finished startup, and I can't figure out how to do that in the terminal.
If you want to do something after you start the emulator you should start it in the background
emulator -avd TEST_AVD &
adb wait-for-device
# other stuff here
adb can wait for a device over a transport to be in a particular state
adb wait-for[-<transport>]-<state>
- wait for device to be in the given state:
device, recovery, sideload, or bootloader
Transport is: usb, local or any [default=any]
To wait until device (or emulator) boots, you can do something like this (as was already answered by Пионерка):
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
Basically:
Wait for device/emulator to be in adb device state
Open shell & sleep in 1 second intervals until the sys.boot_completed property becomes true
If anybody would be interested what Android Studio does, when running emulator, the answer is this class:
If device is online, then it is ready. No need to go to further steps.
Checks system property adb shell getprop dev.bootcomplete until it is equal to 1
For API 23+ devices runs command to unlock screen: adb shell wm dismiss-keyguard
Waits 1 second.
This question already has answers here:
adb cannot start daemon, CreateProcess failure, error 2
(7 answers)
Closed 4 years ago.
Quick Note: I am in the Android SDK "platform-tools" directory.
My problem seems to be a bit of a weird one - Whenever I start ADB with adb start-server, I get the following:
* deamon not running. starting it now on port 5037 *
* daemon started successfully *
Well, Great. It started successfully. Now I try using adb shell:
* deamon not running. starting it now on port 5037 * What??? I thought it already started...
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
Well, Crap. So I open Task Manager and kill adb.exe. Then I run adb shell (without running adb start-server first).
This time I get:
* deamon not running. starting it now on 5037 *
* deamon started successfully *
** deamon still not running **
error: cannot connect to deamon
So, As a brief summary - here is what I have tried:
Rebooting my PC
Rebooting my Phone
Executing adb shell
Executing adb start-server and then executing adb shell
Killing ADB and Executing adb shell
Killing ADB and Executing adb start-server and then executing adb shell
Reinstalling my phone's USB Drivers
Checking port 5037, It is not in use by any other application, and only becomes used by adb.exe when I start the daemon.
Am I missing something obvious? Help me please :P
EDIT: Solution on another question: https://stackoverflow.com/a/29524143/2872279
This worked for me using windows 10.
Open up task manager
Find adb.exe and end its process
Check that you have the correct USB drivers for your Android device installed (they should either include or be downloaded with an ADB driver).
If you haven't installed platform-tools, you need to do so. You can get a copy from the Android Developer's website: https://developer.android.com/studio/releases/platform-tools
If this was already working for you and it has recently stopped, on Windows - try reinstalling the driver and/or checking that the device is actually recognised. You can do so by running devmgmt.msc with + R or from command prompt.
It might be worth just checking that your USB cable is not damaged - ideally try connecting your phone to another computer or with another USB cable. This has been an issue more times than I would care to admit.
check port 5037 is using (another process)
or adb.exe is running (task manager), if running kill process.
I have developed a code to run script on Android real device using Appium server.
Now i want to know android device battery usage during script execution.
Is there any api available in appium to get battery / disk / cpu / memory usage ?
You can use ADB to get all types of information about android device:
To check the status of usb charger and battery:
Adb shell cat /sys/class/power_supply/usb/*
Adb shell cat /sys/class/power_supply/battery/*
Get the current CPU operating speed:
Adb shell cat /sys/devices/system/cpu/<cpu#>/cpufreq/scaling_cur_freq
Get the free Memory:
adb shell vmstat
Reference :
https://sites.google.com/site/adbusefulcommands/