AVD Manager installs pure android. Most of the components do nothing, except that they flood a huge amount of unnecessary information into the logs.The champion among them is com.google.android.googlequicksearchbox. It writes a lot of information to the Logcat and jobscheduler (adb shell dumpsys jobscheduler). Can i somehow remove this component, which is essentially useless and only floods?
For grins I tried:
adb shell
su
pm uninstall package com.google.android.googlequicksearchbox
The system rebooted itself and the package was there again. So no, I don't think it's possible to remove it.
What you can do in Android Studio is, in the Logcat pane, choose Show only selected application (usually on the far right of the header). Then choose your app in the box to the right of the machine selector. That will show only your app in the logcat.
Related
Several years ago, a friend of mine was working on a Samsung S8 Active. He was trying to remove most of the apps on it so it was just a basic phone. He had some instructions for a Ponderosa system. He was having trouble with several things so I was helping him. We got a list of all the packages on the phone using ADB and then copied them into a text editor. We removed the name of any package that we didn't want and then saved the file and pushed it back onto the phone using ADB again. I'm not certain but there might have been an app or something on the phone that had something to do with it as well but the end result was that only the apps on the list were left on the phone. I believe that we could put a password in on the phone and the apps came back but I'm not 100% sure.
Since then I have lost the papers that had the instructions on them and the place we originally got them from no longer has them either. I have another Samsung S8 Active that needs the same system (or simular) put on it. I know how to get a list of all the app package names using ADB.
adb shell pm list packages
But does anyone know of a system that would be capable of removing apps by pushing a file to the phone? Is there an app that would work like I described? Any help would be appreciated.
If you have the list of packages to remove in pkgs2rm, this would uninstall all the packages as long as they are installed apps
xargs -l adb uninstall < pkgs2rm
I am setting up a CI server which creates Android AVDs on the fly to run automated UI tests. This works great, but since the CI gets brand new emulators with brand new images each time a job is run, I get all of the Android welcome and first run and do you agree prompts. These break my tests.
Is there anyway to have the emulator auto-accept or dismiss all of these prompts?
Here are some examples:
After much digging and experimentation, I've figured out a way to work around both of the prompts mentioned above. There isn't a catch-all solution, but here it goes, piece by piece.
Chrome
Before starting up Chrome for the first time, run this command with adb:
./adb shell 'echo "chrome --disable-fre --no-default-browser-check --no-first-run" > /data/local/tmp/chrome-command-line'
Basically, this writes out a file to a known location which Chrome will check on boot. All of the flags specified in the command are obeyed, and those inheriently disable all of the first run prompts. This link was very helpful.
Keyboard (Gboard)
The Android shell has a tool called ime to manage the input methods available on the device. By default, on newer devices in English, the input method is LatinIME. This is the Latin implementation of Gboard, which provided the legal prompt shown above.
The easiest solution is to select another keyboard which doesn't have this prompt. I used the old SoftKeyboard:
./adb shell 'ime set com.example.android.softkeyboard/.SoftKeyboard'
You may obtain a list of available keyboards, like so:
./adb shell 'ime list -a -s'
Final Result
I have many questions about Android command. I do not know where I should start But, anyway, I have put all question related Android commands. Here ;
Is subset of Linux commands come in Android by default ? Or, Are we installing something ?
In system/bin, there are lots of commands. Where can I find their meaning ? I have tried man, but man is not built in.
Can I start and stop application via start and stop command ?
Why cannot I run the reboot from terminal emulator ? The error permission is denied.
NOTE : feel free to reedit the question, if you see meaningless part.
Is subset of Linux commands come in Android by default ? Or, Are we installing something ?
A subset exists by default within the system. Things like ls, cd, mkdir, cat etc... are present. You can gain access to a wider range by installing Busy Box on a rooted device, as stated by Zac.
In system/bin, there are lots of commands. Where can I find their meaning ? I have tried man, but man is not built in.
The ADB Page is a good place to start. That covers many of the basic ADB and shell commands. It states near the bottom:
"For a complete list of commands and programs, start an emulator instance and use the adb -help command."
So you can use adb -help on an emualator or device to see a full list of the ADB and shell commands (note I think this list will be android specific commands only, it won't include things like cd,ls and other basic unix commands).
Can I start and stop application via start and stop command ?
No, it states on the ADB dev page:
start ........ Starts (restarts) an emulator/device instance.
stop ........ Stops execution of an emulator/device instance.
To start an application you'll use the am utility iirc it will look something like am start com.your.packagename It's been a while though, I might have syntax wrong. The instructions are listend if you issue the am command by itself with no params in a shell.
Why cannot I run the reboot from terminal emulator ? The error permission is denied.
The system prevents applications from rebooting the device unless they are signed with the same key as the OS. When you use the terminal emulator you are restricted to whatever permissions that application has declared. The reboot permission is not granted to any third party applications, so it won't work correctly from any terminals. You could probably do it if your device was rooted and you used su though
EDIT:
Here is another good resource that lists more of the shell commands
There are not many Linux commands included in android, however if you are rooted you can easily install busybox which has a large range of linux commands.
You need to have root access to reboot your device via the command line (to prevent any old app being able to do it)
I have two android devices connected to the same station. I would like to view the logcat for both while running them in debug mode in eclipse.
I have had SOME luck with the following steps:
Run the app on Device 1
Run the app on Device 2
Open a new window (window/new)
In the new window, open view logcat
About 40% of the time this results in in each eclipse window showing data from a different phone... but not always. It seems to be almost a luck-of-the-draw kind of thing. More often than not both windows show the same device. If I open device viewer and select a device in either window both change.
How can I do this all the time?
This is a very late reply but probably you didn't find a solution.
Solution:
Click Window ---> Show View ---> Other ---> Android ---> Devices.
Simply click on a device to switch to its logcat.
You can try to use adb in two different console windows to get the logcat for each one.
Example:
in console window 1: adb -s <device01_serial> logcat
in console window 2: adb -s <device02_serial> logcat
As takecare said.
This is how you can do it:
Find the device id's of Device 1 and Device 2. Do this by opening a shell prompt and typing the command
adb devices
You'll get a list of connected devices and their id's.
Run the command
adb -s [device_1_id] logcat
Where [device_1_id] is the device id of your Device 1 which you obtained in the first step.
Open another shell and do the same as in step 2, but for you Device 2.
I don't believe there's a good way to do this. You can approximate it though. One option is (as other answers have suggested) to use logcat from adb. This obviously isn't as pretty. Another is to run DDMS directly (instead of through Eclipse) for your second window. This gets you pretty close and gives you two logcat windows each with their own device selectors. The DDMS executable is found in the tools folder of your Android installation.
Here's the way I handle switching between device's logcat output using Juno M20120914-1800.
Unfortunately it is not automatic, but it is at least the most reliable way I've found yet, and once you get used to doing it, it's not that bad.
I click on the device icon in the toolbar.
I click on the device name.
Then I click on logcat again and it will show the device I selected.
It seems like this should be a feature, to be able to monitor more than one device/AVD at a time.
How do I get root access in order to reboot the emulator? How do I kill all unwanted processes along with the child process?
You have already root access to your emulator. To kill a process and all childs just use the device view in eclipse, select the emulator theere and chose which process you want to kill.
I have no idea on how to restart from code if you are looking for that. Rebooting the device should be easy: just close it and than boot it up again.
(I have the feeling I don't really get what you want...)
Most su binaries for Android depend on SuperUser.apk (available for free through the market). The su binary uses this apk to ask the user if it's ok to do whatever is being requested (and the user can opt to remember the answer). If you're using such a su, you need to also have that apk.
Once the pieces are in place, your application can spawn a process with the right arguments... something like argv[0]="/path/to/su", argv[1]="-c", argv[2]="(whatever command you want to run)", argv[3...n]=arguments to your command.
To kill a process in the command line, simply issue the following command line on the shell:
kill-9 YOUR_PID
If you know the name of the process, but not the pid, use
kill -9 $(pidof NAME_OF_PROCESS)
You can also use it on your code:
Runtime.getRuntime().exec("kill-9 YOUR_PID");
Check the man page for more details: http://unixhelp.ed.ac.uk/CGI/man-cgi?kill
ps-after rebooting i also wanted to kill all unwanted process except my specific app and its child process alone to run in emulator.
If that is really what you want to do - repurpose an android build as a generic embedded linux, then the way to go about it is to regenerate a ramdisk image (which android packs onto the kernel) containing an init.rc which launches your application rather than the android native services and (java-esque dalvik) android runtime. Rebuilding the ramdisk requires a unix-like OS and that arcane cpio command line which you can find in web search. I'd be tempted to leave the startup of ADB in there so you can debug the various things which will go wrong.
For testing purposes simply typing "stop" from the adb shell will shut down the android runtime and give you a UI-less virtual pocket linux box. There will still be some native services running but they may be more help than harm. Ultimately you may need to set OOM killer values on the things you add, though without the runtime up that may not be an issue in the near term if you don't consume much memory.
Or if what you want to do is have a very locked down and limited UI built on top of the android runtime, you would instead develop a custom home screen , test this on an unmodified emulator, and then deploy it on a build customized to lack any means of installing other applications.