Maybe I'm just missing it but is there a way to view WHAT is running in the background on-device in android studio?
I'm getting a battery usage alert on my phone (galaxy s8 - OS v8.0), indicating my app is doing something in the background and I'd like to see what it is.
Thank you
Yea, via the terminal function. This is one of options at the bottom of the Android studio.
You need to run ADB to connect to the device. Once connected you can use Unix command lines to see the processes running.
From google dev : https://developer.android.com/studio/command-line/adb
Also, the command I use to connect an emulator to run unix commands is:
adb -s <DEVICE> shell
Normally the ADB is stored :
USER\AppData\Local\Android\Sdk\platform-tools
and then once connected you can use the following to see the running processes :
https://www.howtogeek.com/107217/how-to-manage-processes-from-the-linux-terminal-10-commands-you-need-to-know/
Hope this helps.
Related
I have requirement like i need to take a UI dump of each window that appears on my android app to verify resource-id given is unique.
basically i want do what this command "adb shell uiautomator dump" does inside the android app.
#CommonsWare may be correct. But I tested the code below on two non-rooted devices and I was able to get an output. (Nexus 6P and Samsung S5)
#Gokul
I found the key was to NOT specify "adb shell" beforehand as it must be in the path already and I get a permission error if I attempt to use it.
Doing something like this:
String command = "service list";
Process process = Runtime.getRuntime().exec(command);
Worked for me running in a unit test on two real non-rooted devices.
This produces the same results as running the command: "adb shell service list" from the command prompt.
I'm looking to uninstall a custom watch face from a running emulator without resorting to wiping the emulator and rebooting. Which ADB commands might I send to the emulator to perform this task?
Just like any Android device, you can use adb. From a command line:
adb uninstall com.your.package.name
If multiple devices are connected, get their names with adb devices and then use:
adb -s device-name uninstall com.your.package.name
For the record, you can also delete a face from a watch as follows
Hook your host phone via usd to a computer with Android SDK
execute adb in shell mode adb shell
pm uninstall com.your.package_name
This will remove the package from the phone and the watch
Ideal for situations where you messed your APK signature leaving package name unchanged.
I'm developing android set-top box app.
So, I have android box and its adb is REALLY SLOW.
When I have to install .apk file to debug my project, I use adb connect [ip address] via wifi and then build & run with Android Studio because the set-top box doesn't have USB port.
But it has serial port so I can connect its shell by screen /dev/tty.usb-serialblablabla 115200. when I use that command, I can see exactly same screen as one of adb shell.
Its adb shell(via wifi) shows very very slow performance.
For example, if I want to run pm list packages, I should type 'pm list packages' and wait for 2min.and then type enter key.(...sigh)
Whereas,Using screen /dev/tty.* methods respond promptly.
I don't know where this difference is come from.
but it is not matter of wifi. I checked its speed. it is quite normal.
In this circumstance, I click Run button in Android Studio after adb connect.
gradle build takes about 10sec.
upload .apk(10.2mb) takes about 10min (sigh).
Because screen ... way is much faster then adb connect way, I want push my .apk into device via 'screen'. how can I do? OR is there anything I can do to reduce time for putting .apk in android device?
You really should find out why adb transfers take so long. But if you insist on using serial console for uploads instead - you could just use any terminal application with XMODEM support on PC side to send the file and busybox rx -b <filename.apk> command on android side to save it. Then pm install <filename.apk> to install it.
I am using adb(Android Debug Bridge) and working with shell in the Genymotion Emulator(I have mentioned every configurations at the end of this question).
I execute "adb shell" and get the shell successfully but the problem is that I get the root access on the emulator. I don't want root shell, I want the normal one as we get when we execute 'adb shell' on the actual device connected via USB. How to achieve it ?
Any help would be highly appreciated.
*Configuration :
Ubuntu 13.10, 32-bit.
Eclipse 4.2 with ADT.
Genymotion Emulator(To be specific, I was using Android 4.3 here).
adb shell setprop service.adb.root 0
adb shell setprop ctl.restart adbd
or
adb unroot
for short.
It has been long since I posted this question but still want to answer it as it might help someone in need.
Main purpose of mine was to get a non-root shell on emulator for some testing purposes but failed to do so after many attempts.
Sometimes back, by fluke, I was fiddling around playstore app inside emulator and indirectly came across solution to above question.
I noticed while creating an emulator, if I used "Google Play" as the image, I got an emulator which was not root.
Follow below steps to get an Android emulator without root:
Create a new virtual device and select the one where "playstore" column has playstore icon (small triangle) visible, as seen in screenshot below.
In next step, download appropriate files needed for creating the device. Make sure to select the target/ABI as "Google Play" and not "Google API". It will make all the difference. In below image you can see I have 2 AVDs (Android Virtual Devices), first (andy_7) with target as "Google API" and another (nexus_5) with target as "Google Play".
Start the avd with target Google Play, nexus_5 in our case and we will get the desired result.
I keep reading tutorials where I'm supposed to enter something into the ADB command line and that it's in my Android sdk/platform-tools. So I find it, click on it, and a black screen comes up for about 2 seconds and while it's up, it scrolls through a bunch of text. So how am I supposed to use this "adb"?
It is called the Android Debug Bridge, and the Android Developers Site documentation does a better job of explaining it than I can:
http://developer.android.com/guide/developing/tools/adb.html
If you are looking for the adb command line, navigate to <sdk>/platform-tools/ and run
adb.exe shell
from the command line.
Pretty sure that is well documented since day 1 on the Android Debug Bridge
Android Debug Bridge (adb) is a versatile command line tool that lets
you communicate with an emulator instance or connected Android-powered
device. It is a client-server program that includes three components:
A client, which runs on your development machine. You can invoke a
client from a shell by issuing an adb command. Other Android tools
such as the ADT plugin and DDMS also create adb clients. A server,
which runs as a background process on your development machine. The
server manages communication between the client and the adb daemon
running on an emulator or device. A daemon, which runs as a background
process on each emulator or device instance.
So plain old English, ADB can be found on %ANDROID_HOME%/platform-toos/, and it's this magical command line that allows you to comunicate with your mobile device, either a physical or a Virtual device (AVD), so whenever you deploy you are passing the application through the device thanks to the ADB on a specific client port on your computer to the daemon port on the device.
Interesting things you can do with it?
Logcat: ./adb logcat allows you to see the log trace of each proces.
Install: ./adb install allows you to install apk to the device.
Killing:./adb kill-sever
Starting:./adb stat-server
Enter SQLite3: adb -s your_device shell
Use the monkey: adb shell monkey -v -p your.app.package 500 to
generate random events
And a lot more! Read the documentation it's beatiful and self-explanatory.