Android project hangs on deploy - android

I'm attempting a very novice Xamarin Forms app and it builds in an instant, but then seems to hang when deploying to the emulator, i.e. I aborted after well over 20 minutes. In the output window, under Xamarin Diagnostics, I get the following last few entries:
[I:]: Found Android SDK. API levels: 22, 26
[I:]: Tracking android devices started
[D:]: TrackDeviceTask got: emulator-5554 device
[I:]: Got new device list from adb with 1 devices
[D:RunShellCommand]: emulator-5554 getprop
[D:]: Tracking avd started
[D:]: avd watcher *.ini path: 'C:\Users\brady\.android\avd'
[D:RunShellCommand]: emulator-5554 getprop
[D:]: avd watcher: got device list from avd with 1 devices
This is my debugging target:
My Xamarin Forms projects were working about a month ago, but since then I experimented with nearly every other Android enabled IDE and maybe that somehow affected my AVD.
What can I look at or change to correct this problem?
I have since learnt I must use the Emulator Manager to create an emulator. Now when I try and open the Emulator Manager, it says I must use the SDK Manager to downgrade the SDK tools to v25.x. When I open the SDK Manager, it says it must be updated, and presents an Update button. Pressing the button directs me to a download page with no download button:
The Get Started button takes me to the docs page for the SDK Manager. Now how am I supposed to update this problem child SDK Manager?

If your project compiles but won't deploy, then Visual Studio is probably not connected to your emulator.
I would recommend using Visual Studio Emulator for Android as it is much faster and has worked on every device I have used it on.
On some computers Visual Studio does not connect to the emulator when it starts. A workaround is to find the devices IP address and connect to it manually:
First open Visual Studio Emulator for Android and start one of the emulators
Next in the emulator select tools, a popup window will open, select the 'Network' tab and under the list of network adaptors note down the preferred IP address. Here my one is 169.254.160.177.
Then in Visual Studio open 'Android Adb Command Prommpt' and enter adb connect 169.254.160.177
Now that Visual Studio is connected to the emulator the application will be deployed to the device. You will need to connect to the emulator every time you restart it (don't close it while your programming).
Note: On some computers, Visual Studio will connect to the emulator automatically.

I re-installed VS2017, but the latest, v15.5.1, then recreated the project, and now everything is working fine. VS even starts the emulator automatically.

Related

How to debug Visual Studio 2019 not connecting to Android x86 AVD

I'm trying to debug a NativeActivity C++ Android application from Visual Studio 2019, using the Visual Studio Android tools.
My system uses Windows 10 Pro, with Hyper-V enabled, running a number of other Hyper-V images (this cannot be turned off for reasons,) but the development Windows install is the "main" (host) OS.
I can build the sample application, and I can attempt to connect it to the VisualStudio_android-25_arm_phone AVD. However, one of two things happen:
If I just run out of Visual Studio, I get the error:
Severity Code Description Project File Line Suppression State
Error Error installing the package. The device 'VisualStudio_android-25_x86_phone' is invalid or not running. Please switch to another device, or use the Android Virtual Device (AVD) Manager to start a compatible emulator, or connect a compatible Android device. XMCRemote3.Packaging 0
If I start the appropriate x86 AVD inside the AVD manager, the device actually starts up. If I then try to run in Visual Studio, I get an error dialog from the AVD Manager that the device and the host have different versions of ADB.
Device error: adb server version (39) doesn't match this client (41); killing...
* daemon started successfully
adb.exe: device offline
This is the Visual Studio log when that happens:
1>Failed to start emulator.
1>emulator: Requested console port 5556: Inferring adb port 5557.
1>emulator: ERROR: x86 emulation currently requires hardware acceleration!
1>Please ensure Intel HAXM is properly installed and usable.
1>CPU acceleration status: Android Emulator requires an Intel processor with VT-x and NX support. Your CPU: 'AuthenticAMD'
1>Error installing the package. The device 'VisualStudio_android-25_x86_phone' is invalid or not running. Please switch to another device, or use the Android Virtual Device (AVD) Manager to start a compatible emulator, or connect a compatible Android device.
1>The device is invalid or is not running.
I don't think I have the "x86 device doesn't work on AMD" problem, as I'm using Hyper-V, and the device starts up and is interactive when I launch it manually.
Sometimes, I think I might have a "ADB port number" issue, because the error message in the log sometimes talks about ports 5556 and 5557, and sometimes about 5553 and 5554. However, I wouldn't know at all where that's coming from, or what to do with it.
And, like in case 2 above, sometimes it just claims ADB is mis-matched.
What can I do about this? Do I need to update the device image, or the local tools? Both were very recently downloaded/installed.
I'm targeting SDK version 21 for both minimum and target versions.
The SDK Tools version is 30.0.4, and the emulator is 30.1.5.
The Platforms installed are 8.0/26 and 7.1/25 (the list only goes up to 8.1/27)
Interestingly, there's no "NDK" version listed in the SDKs and Tools android settings app, even though Visual Studio compiles and links it just fine.
I wonder if the Visual Studio package is installing something on the side? If so, is there another tool to manage what this is than the "Android" sub-menu in the Visual Studio "Tools" menu?

I have to run adb connect 192.168.56.101:5555 in order for android emulator to show up in list

When I start a Genymotion emulator (Android studio emulators crash android studio and dont start), I have to run adb connect 192.168.56.101:5555 in order to connect adb to the emulator. Otherwise it doesn't show up when I use adb devices. I never had to do this before and I cannot figure out why.
Looks like it has something to do with recent update in android sdk platform tools. Downgraded mine from 28.0.2 to 28.0.1 and successfully got my genymotion emulator in adb devices back.
1): Try go to SDK MANAGER in folder EXTRAS and install GOOGLE USB DRIVER
If this happens on a Linux machine you could try to Uncheck the "Use Host GPU" checkbox - in the emulator settings**

Not detecting my android device despite my laptop did

I have been using android studio for the past 5 months and everything was fine. Suddenly, yesterday when i tried to debug my app android studio gave me the error of 'adb.exe start-server' failed -- run manually if necessary.
In an attempt to solve this, I
Killed adb.exe via task manager, restarted android studio and got the error
Opened command window,navigated to platform tools, adb kill-server and adb start-server, restarted android studio and still got error
Then,
I downloaded the latest platform-tools of version 28 something from the documentation.
Updated SDK tools from SDK managet to version 28.0.3
Updated Android emulator to a version of 28
Tried to debug my app, got no 'adb.exe start-server failed' error but my device is not being detected by the android adb despite it is detected by my laptop
Then i started again the command window, restarted the adb server, then i checked the connected devices on the adb by typing 'adb devices' but no devices was shown in the list.( maybe the problem is something here)
I toggled among the usb options on my phone, still my device is not detected on android.
Can somebody help me on this please?
Note: My android device is on debugging mode and this is the same device i have been using since 5 months on android studio.
Install and configure your Android device:
Install the USB driver for your Android device.
Enable USB debugging on your Android device.
If necessary, install the Android development tools (JDK/SDK/NDK).
These libraries are installed by default by the RAD Studio installer.
Add your Android SDK to the RAD Studio SDK Manager.
Connect your Android device to your development system using the USB
cable provided with your device.
At the AutoPlay prompt, select Open device to view files.
In the Control Panel, search for and select "update device drivers".
In the system Device Manager:
Your Android device should be listed under Portable Devices. Locate
and right-click your Android device, and select Update Software
Driver.
Browse to the \extras folder in your installed directory, and
select the folder that matches your Android device. Then click OK.
For example, select google for the Nexus 7 or Nexus 10 tablet.
If you do not find a folder for your Android device, see Installing the USB Driver for Your Android Device.
Verify that your Android device is now:
Listed in Windows Explorer, below the system disk drives, along with your mapped network drives.
Displayed in the Target node in the Project Manager.

Emulator android studio cannot open application

My emulator has problem , I am using android studio, my emulator always waiting for target device to come online. And My emulator name become Emulator unknown emulator-5554 offline...., May I know how to solve this problem, I am using mac windows. Thanks

Intel Hardware Accelerated Execution Manager (HAXM) makes android emulator not show up under connected devices

When I use HAXM with an intel atom cpu for an avd, my avd doesn't show up as a connected device in android studio. This essentially means that everytime I rebuild my project, the emulator has to launch a new emulator instance from scratch instead of running the re-built project on the already running emulator. How do I fix this?
I had to reset the adb. Do this by opening android device monitor aka android debug monitor aka ddms and then right clicking the dropdown arrow and then clicking "reset adb". You can also do this in terminal as shown here: Android Emulator not seen in Device Chooser

Categories

Resources