How to reconnect to running emulator? - android-emulator

When I connect the phone to a USB port, in order to be able to use the phone, I have to kill/start ADB server from the console via adb kill-server & adb start-server.
After this, Intellij losts connection to the already running emulator.
I know that if I restart an emulator, I will get the connection back. Is there a faster way to simply reconnect IntelliJ to already running emulator?
Thanks in advance

You can attach to already running emulator via a "cloud" button in Android Logcat pane:
Sometimes this button needs to be toggled several times to have effect.
In IDEA 10.5 there is now a button that also attaches debugger to already running Android app: http://blogs.jetbrains.com/idea/2011/05/new-in-105-attach-debugger-to-a-running-android-process/

Related

Android Studio device list stuck on loading

Picture of the issue
I'm trying to add my physical phone to the device list, however, the device list is stuck on loading.
I try to Kill adb process (on Task Manager on Windows) and Open Android Studio
And also I Try to reinstall Flutter and resetting the Flutter SDK, but still the same problem.
For me this fixed the issue:
First close the android studio and kill the all the related bg
processes.
Restart pc and check there are no bg processes running.
Now connect your Android Device (make sure USB debug is enabled).
Revoke the debug permissions and then allow debugging.
Now on pc run adb devices command from terminal.
If your device is displayed then proceed to open Android Studio and
wait for some time.
Also make sure that there is only one version of adb is installed.

Flutter: 2.2.3 - How to solve the error: Error connecting to the service protocol: failed to connect to http://127.0.0.1:XYZ

When I create a clean flutter project(flutter create proj_name) Then I try run it in debug mode from vs-code on a real device android 5.1.1 and it starts and works fine for the first time, but if i stop application and run it in debug mode again the following message like this results
What helps to run in debug mode the application is restarting the real smartphone so it will work until you stop the application and try to run in debug mode again.
Does anyone have any suggestions how I can solve this?
The error points out that it has issues connecting to the Android emulator. Checking the flutter doctor logs, the emulator doesn't seem to appear. Try restarting the emulator using cold boot. Open the Android Device Manager and click on Cold Boot Now on the emulated device. Then run flutter doctor --verbose to check if the emulator can now be seen in the list of connected devices.

emulator broken: This adb server's $ADB_VENDOR_KEYS is not set

Well a windows 10 update broke sleep, the computer went to sleep with the emulator open and now that's broken. When I run an app to launch in the emulator it will boot the emulator but won't install just time out. When I try and run an app into a running emulator instance Studio says:
com.android.ddmlib.AdbCommandRejectedException: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
Error while Installing APK
I've followed some of the other threads here. I've tried changing
the environmental variable in control panel, but in fact I think it
pointed to the right place originally, where the sdks are these
days.
I've tried restarting the PC. I did try deleting a couple of
adb files, that didn't work.
I've tried deleting all the sdks and
downloading them again.
I've tried uninstalling and updating Android
Studio, several times. Now on AS 3.1, still not working.
Bit of a nightmare really.
How do I set the vendor keys? Using AS console commands? Can anyone point me to a dummies guide, this is a bit of a tangent for me, wish I could fix it from the GUI.
The working fix for this particular issue is to enable Developer options on your emulator and enable "USB Debugging".
OK so eventually downloading a nexus 4 x86 image android 27, with no play store worked. Sorry if this is repetition. Long live working emulators
Combining answers from here and there gives an answer that also worked for me in IntelliJ IDEA. I assume the issue is the same, since the emulator and AVD is the same.
Option 1:
Restart the emulator from AVD
Option 2:
Wipe the emulator data
Option 3: Stop the emulator. Then make sure it is up to date and try again.
If it still does not work, restart the adb server and retry.
adb kill-server && adb start-server
If it still does not work, perhaps your adb is out of date... somehow. This was the case for me. Running the following fixed that for me.
adb devices
adb server is out of date. killing...
* daemon started successfully *
List of devices attached
emulator-5554 device
If it is now working for some emulators but not newly created ones, take note of the message in the emulator selection box: "Press Ok in the Allow USB Debugging Dialog"
Sadly, there is no such dialog. So go and enable Developer Mode in the settings of your emulated OS by tapping the Build Number several times. Then go to the Developer Settings and enable USB debugging.
After recent upgrades of emulator, the virtual device*) stays unauthorized. When I cold boot the emulator, sometimes I see the expected confirmation dialog, but this dialog goes away immediately, leaving no chance to click 'OK'.
We're aware of this problem and plan to fix it soon.
* Here, I was running x86 with API 28 and Google Play on Windows 10. I don't know which other scenarios are effected.
For anyone who might encounter this in the future -- I mean the ultimate issue of receiving the error, "This adb server's $ADB_VENDOR_KEYS is not set" despite not having any (or any sufficient) opportunity to click OK...
Resolution: In the Developer Settings, select the option to, "Remove existing authorized adb keys on device." Repeat the previous action -- the prompt will once again appear, as if the very first time.
-Mike
Go to developer options in your device and click on 'Revoke USB debugging authorizations'. Disconnect and reconnect your device. You'll get a prompt on your device to authorize your computer to connect to your device. click on 'OK' and your set.
Basically, the authorization key has gone out of date or it's no longer present. So, we just have to set a new autorization key and revoke the old ones.

How to prevent launch Ionic app on emulator

I'm working on ionic App and I'm trying to run App on real Android device, But when I run ionic run android in terminal, I get the following error:
Running command: "C:\Program Files (x86)\nodejs\node.exe"
D:\wamp\www\pars-app\pars-app\hooks\after_prepare\010_add_platform_class.js
D:\wamp\www\pars-app\pars-app
add to body class: platform-android
ANDROID_HOME=D:\Sdk\android-sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_45
No target specified, deploying to emulator
ERROR running one or more of the platforms: No emulator images (avds)
found.
1. Download desired System Image by running: "D:\Sdk\android-sdk\tools\android.bat" sdk
2. Create an AVD by running: "D:\Sdk\android-sdk\tools\android.bat" avd HINT: For a faster emulator, use an Intel System Image and install
the HAXM device driver
You may not have the required environment or OS to run this project
How to prevent run app on windows emulator? I want to run app on real device that conected to my computer.
I am using windows 8 and Huawei with Android 4.2.2
::note
I have read these questions, But I didn't got the answer!
Why not work Ionic app testing on android real device?
Ionic run android does not run app on device
ionic run android - configurations not running app on device
As a complement to #OClyde answer, you could try :
adb kill-server
adb start-server
To have infos about these commands :
adb --help
Nb : Sometimes, for a reason i do not know, the connection between my phone and the computer break. Running this fixes it.
To make sure that your app is not installed to an emulator but to your device, take the following steps:
Open up your console and run adb devices. This should give you a list of all devices available (real devices as well as running emulators) to the Android Debug Bridge. If the adb command is not recognized check that you have installed the Android SDK correctly and that you've set all the necessary environment variables accordingly.
The adb devices command might give you output similar to this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
This indicates that the ADB wasn't ready before, so in this case just try to un- and replug your device and run adb devices again to see if the device is listed afterwards.
If your device is still not showing, check that USB Debugging is enabled on your device. Therefore you first have to enable developer settings, which you can do by tapping the build number (Settings => About Phone) 7 times (no, that's not a joke ;) ). After that, you'll have the developer options in your settings menu. Open these and check "USB Debugging"
If still your device isn't recognized by the ADB, change the USB connection mode. You can either do this in the developer options as well or tap the notification shown when the phone is connected to your PC. Try MTP as well as PTP, on of those should do the job.
After these steps, it should be nearly impossible that the device is still not recognized by your PC. As soon as there is a phone available, Ionic will install the app on the phone automatically instead of launching an emulator.

android 2.2 emulator -- Fails to load Wi-Fi driver

I can't connect my emulator -- Target: Android 2.2 -- to connect to my home wifi that I know works ok. (Had also been able to do that a couple of months ago.) The emulator displays "(No Service)" on top right of start screen. LogCat shows:
10-26 05:53:16.531: INFO/WifiService(60): WifiService starting up with Wi-Fi disabled
...
10-26 05:57:44.963: ERROR/WifiService(60): Failed to load Wi-Fi driver.
Have tried running Dev Tools > Connectivity > Enable Wifi, but only see another "Failed to load Wi-Fi driver entry in LogCat.
But emulator -- Target: GoogleAPIs on Platform 2.1-update1 -- displays "Android" on top right, and seems to connect to the same home wifi fine. Eclipse and emulator run on my Windows XP laptop.
Appreciate any insights...
CL
The emulator will do networking, but the wifi doesn't load a driver due to not being able to access the host hardware.
You need to test wifi code natively.
I also encounter such problem when trying to perform WiFi scanning from the emulator. However when i tried running the program on my physical device, no such problem encountered.