Android Emulator - offline to online mode - android

Is there a way to bring android emulator from offline to online mode without closing AVD?
I tried adb's 'kill-server', 'start-server' commands but this just seems to re-start adb server (adb.exe process), the emulator is still in offline mode and 'adb devices' still show 'offline' state.
Also can someone explain what exactly 'offline' mode of emulator means.
In my case - Emulator (standalone), daemon process and ADB server - all seem to be running. Why is emulator state still offline?
Updating Question:
I have tried 'adb reset' both from Eclipse & command line that does not solve the problem. Issue seems to be more with Emulator Memory. Per my analysis memory of emulator keeps increasing and after a limit (~470 MB in my Windows) if you try to do a adb reset - it brings the state of emulator to offline and no more adb commands work. (also no network calls seem to be working)

If you just created the emulator, in the emulator settings:
1.just click on "About the emulator" -> "Build Number" about 5-7 times.
2.This will open "developers options", go back and click on it and enable "USB debugging"
to bring it online.

Use these commands from the command prompt it will help u
1.adb kill-server //kill all active server
2.adb start-server //start adb server
3.adb devices //check the list of active server

Sometimes/most of the times the solutions described above works. But if it does not, and you had "Launch from snapshot" enabled, killing the emulator and restarting it WITH LAUNCH FROM SNAPHOT DISABLED, will let you of the hook.
I had this problem many, many times in the last few weeks, and although adb kill-server followed by adb devices works 4 times out of 5, that fifth time the only way to get it working again is by disabling the 'launch from snapshot' option. My guess is that the emulator is somehow in a 'wrong' state, but do not understand why myself.

I have faced this problem many times. Some solutions are:
Solution 1:
the emulator
Select & Right Click on Android Project
Run Configurations
Go to tab Target
Enable option Wipe User Data on Emulator launch parameters
Run Application
Solution 2:
Run Emulator
Keep the Emulator, (no matter same error occurs)
Make Sure the Home Screen of Emulator is appeared
go to Window -> Show Perspective -> DDMS --> In Devices Panel -> on Corner Drop Down Menu
Reset adb
Solution 3:
Reset adb manually or using the command line.
Might be helpful for a new user.

This issue can be solved using the below steps:
Open AVD-Manager in android studio and choose the emulator which you want to run
and do the wipe data and cold boot, take reference from the attached pic:
If the doesn't work, go to emulated device and enable the developer options >
enable USB debugging.

Related

Android debugger continually disconnects

I have never had an issue debugging in Android until I switched to my current workspace. It happens in both Eclipse and IntelliJ. Previously I had an issue where the phone would hang at the "Waiting to attach debugger" dialog. Somehow I fixed that so the debugger at least attaches to my app.
Now I can set a breakpoint and have the debugger stop at that point. After about 5-10 seconds it disconnects no matter what I do. I'm able to read a few values of variables in memory before everything disappears. My co-worker is able to debug the same app just fine using Eclipse and we haven't been able to figure out what is wrong or different between our workstations (besides me using IntelliJ). We might have different images for our laptops though.
Any ideas? I've had to use Log statements for now but they are just too slow compared to using an actual debugger. I've tried using different USB cables and that didn't make much of a difference. I've gone through the debugger settings and nothing seemed out of the ordinary. Other Q/A's on SO have mentioned the app silently crashing, but I'm ruling that out due to it debugging fine for my co-worker.
I've been having the same problem running IntelliJ IDEA build IC-133.193. I solved the problem with the following actions:
Quit IntelliJ
From a command line kill the adb server with adb kill-server
From a command start the adb server as superuser with sudo adb start-server
Restart IntelliJ
IntelliJ will start the adb server if it detects that it is not running. The key appears to be starting adb as superuser before starting IntelliJ.
[Update] This doesn't always work. The best solution I've found is to start the app on the device and then attach the debugger to the Android process through the Run menu. I haven't had any disconnections using this method.
I have been fighting for a few days with adb not seeing my device. After trying many other posted solutions, I discovered that the issue was with Chrome also trying to connect its debugger to a web view. If Chrome is connected using chrome://inspect, then adb seems to disconnect. Quitting Chrome resolves the issue. Then I can connect with Android Studio and then restart Chrome and reconnect. Hope this helps someone else.
This fixed it for me
Go to Power Options on your computer
Click 'Change plan setting' on your chosen plan.
Click 'Change advanced power setting' on your chosen plan.
Expand 'USB Settings' .
Expand 'USB selective suspend setting' and change it to disabled.
This issue occurs to me when I try to use a USB 3.0 port. Using a USB 2.0 it does not happen.
This happens to me when the cable connection is sensitive.

emulator doesn't show in device view in ddms

When I try to debug using one of the configurations that I've set up (for example Android233), the emulator never actually launches. I just see a little green icon in my task bar that says "launching Android233," but it never launches. I've let it sit there for hours and it never does anything. I don't know if this is related, but my emulators don't show in device view in the DDMS perspective. I have a physical Android device, which shows up in device view. My question is, what is happenin' and how can I fix it?
Thanks for taking the time to read my question :)
I thought I had the problem figured out, but it stopped working again. Here's more information: When I run my debug configuration, in the lower right corner of my Ecplipse windows it says:
"Launching MyDebugConfig (100%)" and then there's a green icon next to it.
I looked in task manager and the emulator is not in there. I looked in DDMS and my AVD is not listed and there is nothing in the LogCat or Thread or anything else for that matter. I have my debug configuration set to prompt me to pick a device, but it never does that. It just loads my AVD, even if I have my phone connected (which is visible in DDMS). I'm so stumped. I've had this problem since I started using Eclipse and I don't know what to do.
Thanks.
Go to DDMS Perspective =>Click View menu=>reset adb
If Your genymotion virtual device is not seen in android device monitor then just try this.
1. start android studio
2. start Android Device Monitor
3. Lastly start the genymotion virtual device it will appear
The emulator won't show up in the DDMS section until its running.
The emulator won't lunch probably because you misconfigured it, currently the lunch dialog of the emulator doesn't support error messages, however you can get the lunch stack trace while you try to lunch the emulator via Eclipse.
Disconnect your physical device, run your project and select the emulator. you should see an error message on DDMS console.
If you in Windows try run (after starting emulator)
adb.exe kill-server
adb.exe start-server
and wait for restarting your adb

How do I restart an android emulator?

I'm basically trying to do this:
Changing the Android emulator locale automatically
Everything works up until 'start'. the emulator starts to boot but keeps loading at the shimmering 'ANDROID' screen forever. I must be missing something... How can I restart the emulator from ADB?
Okay, I should be more specific.
I am trying to do this from the command line using adb. I can use adb to setprop and I can stop the emulator. When I try doing 'start' in the adb shell, the emulator does begin to boot, but it never returns to the lock screen.
In Android Studio go to:
Tools > Android > AVD Manager
Select your emulator device
Click "Cold boot now" to restart, or "Wipe data" to factory reset
you can try
emulator #avd_name -no-snapshot-load
it will clean load the device it worked for me.
You asked how to restart the emulator from ADB. But the title is framed in a way that pops the question up when searching about restarting it from the UI as well.
One option could be (but it depends on which tooling you are using and may not be available for all emulators/environments) is to tap and hold the Power button and then a menu will pop up with a Restart option in it.
This was a long-standing default behavior, but since Android 12 / API 31 it tries to open the Google Assistant instead (even when there's no such thing on emulators without Google APIs or Google Play 😵). The old behavior can be reverted by going to Settings > System > Gestures > "Press and hold power button" to bring up the menu in the screenshot.
To restart a running emulator I used
adb -e reboot
(Assuming there is only one running)
I'm pretty sure this will work:
Clear/Wipe the AVD to defaults or create a new one.
Start the AVD/Emulator from the CLI with the following command
emulator -avd my_avd -prop persist.sys.language=en -prop persist.sys.country=GB
change as needed. That way you are not messing with the system image which can cause hangs/crashes. And you can easily set it on boot for a variety of Locales.
If you are using Android Studio, you can goto the AVD Manager, Under Actions select "Cold Boot Now" to restart the emulator. This would get rid of errors/discrepancies which might occur if the simulator's process has been abruptly closed/terminated.
For me, kiran-chenna's answer failed me, and the solution was to instead run:
emulator -avd Pixel_2_API_28 -no-cache
In my case, a cold boot was required after the emulator got stuck. It can be found in the Android Virtual Device Manager.
on Android 13, when you swipe down to the notifications, and swipe down again, you get a power off button on the bottom right:
which has the Restart option:
Follow the following steps to restart/cold-boot your virtual device:
Open Android Studio
Click on Configure
Click AVD Manager
Click on the Dropdown on the right hand side of the virtual device.
Click on Cold Boot Now
You're done! The device will restart within a couple of minutes.
2022 Android Studio Bumblebee: With the emulated device open on screen (the "Emulator" tab open), press and hold the power button at the top of window just as you would on a real device, and it will pop up the device's menu just as if you had held the button on the side of a real device. For example:
If the power button (top left of Emulator) is opening up assistant:
Tell/type to Assistant to open "Settings" (or double drag down the battery/antenna icon on top right)
Search for "Power"
Go to "Power Gesture"
Turn that off!
To start/stop or restart emulator follow these steps:
using telnet on windows machine
or localhost 5554
avd start start
or
avd start restart
or
avd stop
Some versions of the emulator (android-7) are buggy and just hang at the shimmmera.
Try restarting it with "wipe user data" option (yes, you will have to re-run your
app or at least reinstall it).
You can try this
emulator #avd_name -no-snapshot-load
or else Simply delete the existing AVD and try to create a new one.
By following the steps.
In Android Studio > Tools > Device Manger > Create Device
you can restart the emulator from adb shell,
start the emulator and also adb shell in the terminal.
start Starts (restarts) an emulator/device instance.
stop Stops execution of an emulator/device instance.
in eclipse in the top most right u will find DDMS go i there, left side you will find Devices and in that in the last you will find a triangle downwards press that in that you will find Reset adb.

Adb stops detecting my phone after a while

I am developing for android on a linux machine and I have already created a udev rule for android and it works. After a while if I unplug the device and plug it back in again, adb doesn't recognize the device if I run lusb or dmesg to get information about the device. I tried reload the udev rules and it does not work, I even tried to kill the adb process but it still does not work.
Can someone help?
Anyway, thank you.
This appears to be a real problem on linux, at some point in time a device will no longer be seen by the ADB. What I should really say is almost never be seen by the ADB. In my case I have a Samsung Galaxy Tab 10.1 that was given to attendees of Google I/O 2011. My Ubuntu 10.10 development system was working just fine with this device. Sometime near September 19th the ADB stopped seeing the device! In fact there have been breif moments in time when the device was detected by the ADB. What needs to be made clear about the problem that I and I believe pharaoh are having is not the permissions issue where executing
$adb devices
returns ?????????? for a device. The device simply does not show up in the list. One more important fact is that at no point in time has this device not been detected on my Windows based development machines.
It appears to me that the mechanism that the ADB uses to determine if a device on the USB is in fact a adb_device is fragile and some change in either our devices or our development systems has broken this detection.
Due to some reason sometimes adb gets disconnected, so in that case you have to restart the adb.
Go to DDMS->Devices and you will see Reset adb option in View Menu besides Screen Capture option.
I usually have this problem due to I have installed the adb plugin on Chrome. If I close Chrome and re-connect the device, it appears listed with adb. Hope this helps.
I just had this problem as well with my OnePlus 2.
It was working the previous day. I had then set up port-forwarding using the 'device inspector' dialog in Chrome DevTools. It's supposed to be kept open for it to work, so I kept it open in a tab permanently.
The next day when I connected my device via USB, adb devices didn't list anything. I closed the device inspector dialog in my devtools and suddenly adb recognized my device again. I re-enabled port forwarding after this, but my device is stll being detected.
tl;dr: Close your port-forwarding dialog in Chrome DevTools if it had been kept open even after you removed your device.
I've had this happen before. I disable, and then re-enable debugging on the phone (Setting -> Applications -> Development -> USB debugging, uncheck, then re-check) to get it recognized by adb again.
Try adb kill-server to stop the adb and use another command 'adb devices' to restart it. It should work and it should detect your device again. ( For those who can edit my post: any other commands will start the server not just adb start-server, so don't edit without to leave a comment at least)
May be stupid, but I have been had similar problem right now and after an hour I noticed that the problem was that my USB hub, in which such devices are connected, were not actually connected to the PC.
In fact, the USB wire WAS connected, but they may not being doing good contact for some reason, so it failed randomly from time to time.
Same problem here, using mac os. However connected devices are recognized by Android File Transfer application. It all started with S3 phone (rooted), I thought something wrong with the phone, because Nexus 7 (stock) worked as intended. After 3 days of connecting/reconnecting it stopped being recognized by adb too. Tried to perform a hard reset - didn't help.
adb list - empty list
android file transfer - works perfectly
I'll run out of devices soon
Same problem observed on ubuntu, I tried the following and it worked:
Reference: link
Use the command udevadm from the above reference for ex:
"sudo udevadm test --action="SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="[vendor_id]", ENV{ID_MODEL_ID}=="[model_id]" MODE="0666", SYMLINK+="[Device_Name]"" $(udevadm info -q path -n /dev/bus/usb/001/[DevNum])"
This seems to fix some link files and that solved the problem of adb not detecting device after a while.

Reconnecting Emulator to Eclipse

My main problem with developing in Android is that the emulator seems to continually get disconnected from eclipse. This always happens the 2-3 time I try to upload my .apk from eclipse without rebooting the emulator. Eclipse indicates this with an empty DDMS ->Device section and logcat stays blank - sometimes I'm not sure if the new code made it on the device.
The only fix I have for this is to shut down eclipse, and restart it. With the restarting of Eclipse, on top of the emulator boot time, I can't get any momentum going in my development.
Is there a way to reconnect the emulator to eclipse without having to restart Eclipse or even the Emulator?
Update: There were a couple of answers that helped, particularly "reset adb" or Kill-server -> connect adb. However, sometimes even that is troublesome.
I am going to try Pentium10's suggestion of hooking up my G1 and using it as an emulator, but for now, I have found that if I don't see my logcat going, and the emulator is working (This is my biggest problem, because I am outputting all my debugging messages to log) then I can open up CMD and type adb logcat. This streams the log into the command window. Not nicely color coded, but nice enough for me to find my problems...
In eclipse go to Window->Show View->Other->Android->Devices. When your application is run go to this tab and you will see the emulator. If your emulator becomes unresponsive, in the devices tab you will see a down arrow at the right. Click the arrow and a context menu shows up. Hit the option Reset adb.
Just had to do this and it worked beautifully, but it did require you to reset the emulator - though I didn't wait to see if it reconnected on its own.
Try to call 'Reset adb' menu item from DDMS > Devices tab. It helps me in this case.
At most of the time you don't need to restart the emulator.
AFAIK the only workaround for this is to restart Eclipse (I always use this), or use a real phone.
Try adb kill-server, followed by an adb connect
I've had luck reconnecting to the disconnected emulator by entering an adb-over-tcp command line which you can look up in the docs. I think the address and port to use are the ones in the title bar of the emulator window, if not try the next higher port. Once it's back in adb devices eclipse should use it.
in terminal:
$adb kill-server && adb start-server

Categories

Resources