we have android + linux m/c, we log in into linux shell and boot the machine in android GUI.
now we have the some script that is running on the same machine through linux shell. In that case when the script hangs we need to restart android machine. but it result into restarting the linux machine too. as they are on same machine. so i need the way to restart the android so it comes out of hang state and control remains on the script that is running through the linux shell.
so is there any adb or linux command that work for me?
Have you tried simply 'reboot' with adb?
adb reboot
Also you can run complete shell scripts (e.g. to reboot your emulator) via adb:
adb shell <command>
The official docs can be found here.
You can reboot the device by sending the following broadcast:
$ adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
adb reboot should not reboot your linux box.
But in any case, you can redirect the command to a specific adb device using adb -s <device_id> command , where
Device ID can be obtained from the command adb devices
command in this case is reboot
I think the only way to do this is to run another machine in parallel and use that machine to issue commands to your android box similar to how you would with a phone. If you have issues with the IP changing you can reserve an ip on your router and have the machine grab that one instead of asking the routers DHCP for one. This way you can ping the machine and figure out if it's done rebooting to continue the script.
Related
I am using Android Studio 2020.3.1.
I want to launch a adb shell from within Android Studio.
I have the Terminal tab at the very bottom of the IDE.
But I can only open "Local" terminals.
Any ideas where I can launch a "Remote" adb shell?
Within you local terminal, you can easily start an adb shell with the command adb shell
Locate adb if it's not already in your executable paths environment variable. The location largely dependent on the OS you use and where you install the Android SDK. In general it's in the ${ANDROID_SDK}/platform-tools/ directory.
Execute adb devices. This will list the connected adb capable devices. If you are not running any emulators and you only connect your phone then your phone would show up (if not then you may need to treat some permission steps depending on your operating system). Let's say the ID of your device is XYZ.
Execute adb -s XYZ shell and you'll be in a shell on your device.
I am trying to connect a vagrant machine that I setup, to an android emulator on my normal machine by using :
adb connect 10.0.2.2 command on my vagrant machine, than i have this output :connected to 10.0.2.2:5555.
however when i do adb-devices i have this output :10.0.2.2:5555 offline, which is weired because my emulator is actually running because when i do adb-devices om my normal machine i have this output :
List of devices attached
emulator-5554 device
I have already tried to kill and restart the adb server several times but i still have the same problem
Can please someone help me with this ?
Thank you in advance
Working out how to get this going took me a silly amount of time, but this is the gist of it:
The android server should only run on your host machine. If your android emulator is running, I believe it automatically keeps the adb server running (on the host).
In the Vagrantfile, enable the public network option (to give the vagrant machine its own IP) https://www.vagrantup.com/docs/networking/public_network.html
Get the vagrant ssh config with vagrant ssh-config
Use ssh directly to the vagrant (not vagrant ssh) as follows: ssh -R 5037:localhost:5037 -l vagrant -i [private key path] [vagrant machine IP address]
The -R 5037:localhost:5037 directive tells SSH to create a reverse port-forwarding, with 5037 being the port the adb server uses. So any adb commands run on the vagrant machine will connect to the adb server running on the host machine, which will in turn execute them on the emulator (adbd).
So this method is successfully splitting the three adb systems (adb client, adb server, adb daemon) across the 3 machine instances respectively (vagrant, host, emulator).
https://developer.android.com/studio/command-line/adb.html
To test it is working, run adb devices on the vagrant machine, and you should see the emulator in the list.
I can't remember exactly why (I think it was several reasons), but trying to use adb connect is a dead-end.
This is my first post here, so first of all, hello everybody!
I am not sure if it is bug or a feature:) but I have noticed that when you will run adb install with no device connected, it firstly starts adb daemon (if was not currently running), and then wait for the device. After that, when you open new window and run adb kill-server, adb install command will not stop, but shows protocol fault and then restart adb daemon again.
There is no other way of stopping this, than killing the process (for example using ctrl+c).
Screenshot
I have also noticed that other commands like adb shell, adb devices, adb wait-for-device doesn't act like adb install - stop when adb kill-server will be lunched.
My version of ADB is 1.0.31
I have tested this issue on Linux and Windows, and both works the same.
Please let me know, what do you think about it.
Best Regards,
Pawel
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.
We are able to run instrumentation tests of Android from the command line on Windows by launching:
adb shell
am instrument -w <package.test>/android.test.InstrumentationTestRunner
This gives us good results.
Using the same architecture, we are unable to run the same in Kubuntu.
We have the same setup in Kubuntu.
Can someone let us know, if there are packages with same name.. Then what package will the adb shell point?
How will the emulator connect with adb shell from cmd line?
DO we need to do any changes to do so in Kubuntu ?
You need to explain what errors you are seeing.
If you have the same setup under Kubuntu, i.e. the Android SDK is installed, with tools like adb accessible in your path, then everything should work fine.
In response to your individual points (and these answers are the same on Windows, Mac or Linux):
It is not possible to have more than one Android package installed on a device or emulator with the same package name.
You can connect to the emulator — the same as for any device — by calling adb shell, e.g.:
adb -d shell if you have a single USB-attached device
adb -e shell if you have a single emulator running
adb -s emulator-5554 shell to specify a particular emulator (or device serial number)
You don't need to change anything between operating systems. The difference would be with setting up a device, as you need to modify udev rules on Linux, and install the USB driver on Windows