Getting an error when running xamarin project? - xamarin.android

I am new in xamarin, create a sample application using xamarin android native, when try to run get an error
C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -partition-size 512 -no-boot-anim -avd Android_Accelerated_x86_Oreo -prop monodroid.avdname=Android_Accelerated_x86_Oreo
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
Emulator Android_Accelerated_x86_Oreo cannot be started.
Runtime checks completed
Build has been canceled.

In Visual Studio go to Tools -> Android -> Android SDK Manager
Then make sure Android 8.0 / 8.1 (whichever one you're targeting) is installed.
Next in Visual Studio go to Tools -> Options -> Xamarin -> Android Settings
Then make sure you have the appropriate paths specified in Java Development Kid Location and Android SDK Location (should see little green checkmarks).
Also check the box to "Auto Install Android SDKs".
If something is screwed up still, would recommend going to Visual Studio Updater, then confirming Xamarin workload is installed or try to repair.

Related

Xamarin.Android when startup tracing is enabled, app cannot be deployed (NDK MISSING)

I am tring to speed up the launch of my xamarin.android app (forms).
But after it has compilied it says:
Could not locate the Android NDK. Please make sure the Android NDK is installed in the Android SDK Manager, or if using a custom NDK path, please ensure the $(AndroidNdkDirectory) MSBuild property is set to the custom path.
But only with startup tracing enabled. Taking it out, and everything works again.
How is that possible?
Best,
J
Here are several workarounds for this issue:
You can set your Android NDK locations here is a document about it
https://learn.microsoft.com/en-us/xamarin/android/troubleshooting/questions/android-sdk-location?tabs=windows
If you cannot change the default location of the Android NDK through the settings,
make sure you installed NDK, if not: Tools > Android > Android SDK manager > Tools > select NDK > Apply Changes
and
Create a folder named "AndroidNDK64" in C:\ProgramData\Microsoft
then Move the C:\ProgramData\Microsoft\AndroidNDK64\android-ndk... folder to the folder you just created
To resolve this issue I had to uninstall the NDK, and install the latest Side by Side NDK.
This is done by doing the following in Visual Studio Community 2022:
Open the Android SDK Manager via Tools -> Android -> Android SDK Manager
Tools tab
Expand NDK and de-select the installed NDK (if any)
Expand Other. If Other is not visible, click the Great icon (options,) Repository, and select Full List.
Within Other, select the latest NDK (Side by side) option. I selected the latest 4 versions on a whim.
Click Apply Changes to uninstall the old NDK and install the NDK (Side by side) versions you've selected.
After doing this, I was able to deploy to my device with the Startup Tracing build option enabled.

Android Studio : "Unable to locate adb"

I just installed Android Studios and trying to build my first app. When I press play on the emulator the message "unable to locate adb" pop-up. How to solve this problem?
I had this problem when updating to Android Studio 4.0.
I even tried uninstalling (and doing a full cleanup) Android Studio and installing again. The problem persisted.
The problem was that when importing my old project, the new Android Studio couldn't find the SDK and my project had no SDK (even though it could build, go figure).
So check File -> Project Structure -> Project. In my case there was a big red NO SDK set there. Once I set the SDK to the one installed, problem was solved.
I guess you didn't set the system and user environment path in your windows.
Goto properties of This PC > Advanced System Settings > Environment Variables > Path > then put the path file location.
intel android driver setup install this after its worked for me

Android Emulator not running

I am new to mobile development. Trying to follow tutorialspoint for my first xamarin android app. The emulator fails to start.
Emulator is set to use android 9.0. When running directly from Tools -> Android -> Android Device Manager, emulator runs but crashes. When running from Visual Studio debug, comes up with following error.
"Starting emulator testdevice ...
Checking HAXM compatibility.
Emulator testdevice cannot be started.
Runtime checks completed
NuGet package restore canceled."
where 'testdevice' is the name of my emulator.
Have been on Tools -> Android -> SDK Manager, then on Tools tab. Then Under Extras, I've selected the HAXM installer and clicked apply changes.
I've been looking online but nothing seems to help.
You might want to verify haxm support. On a command prompt type
sc query intelhaxm
For more info, refer to
https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/hardware-acceleration?pivots=windows

Build failed with error Remotebuild requires your projects to use cordova-ios 4.3.0 or greater with Xcode 8.3. Please update your cordova-ios version

I am aiming to deploy a mobile application to the iOS platform using codes developed in Visual Studio for an Android phone. I am unable to open the Visual Studio file on my Macbook (macOS High Sierra ver.10.13.6) as Visual Studio here does not seem to support .jsproj files. As such, I have attempted following the instructions in the link below to run a remotebuild on my mac while debugging codes and seeing an iOS simulator on my Windows computer.
https://learn.microsoft.com/en-us/visualstudio/cross-platform/tools-for-cordova/first-steps/ios-guide?view=toolsforcordova-2017#run-on-simulator
I was able to get the remotebuild running, however, I came across the error where it required my projects to use cordova-ios 4.3.0 or greater with Xcode 8.3. As my windows computer does not have Xcode, I turned to my macbook and tried updating and adding the Cordova iOS platform through the terminal, where it said "Current working directory is not a Cordova-based project." I have searched the error up and it said that it required my Visual Studio project to be open, which I am unable to do so as my file is not supported in the Mac version of Visual Studio.
The iOS version in my Windows Visual Studio is currently 4.2.0 and I am unsure how to get about updating it. I have seen the link below but in only applies to Macbook, where I cannot open the Visual Studio project file.
Install specific version of Cordova CLI in Visual Studio 2017
I have installed node.js as well as Git, also attempting to include/update the Cordova iOS platform through the command prompt (Once again unsure if that was the method, but I tried), however, the command prompt did not recognise the update to cordova. Under the toolset in Visual Studio, I have tried ticking on the checkbox under Cordova platforms to take the latest patch, where ~4.2.0 appears, but still does not update.
I am still new to coding and things seem very foreign to me, if I have missed out anything vital or am doing something fatally wrong, please do enlighten me.

Can't get Visual Studio to target the correct Android version

I have a problem getting Xamarin.Android to target the newest version of Android.
The problem arised when I tried installing the Xamarin.GooglePlayServices.Maps NuGet package, that required me to run at least Android 8.
From my Android SDK manager, I can see that Android 8 and 8.1 is the only SDK platforms installed:
However, when I start a new project in Visual Studio 2017, and go into the project properties, and extend the Compile using Android version dropdown, it's populated like this:
So here I can choose only 7.1 (that is marked as latest platform), and 8.0 and 8.1 is marked with (Requires installation). Android 7.1 SDK that VS uses is not even installed on my machine.
So the questions is: What do I have to do to select Android 8.1 as the Target Framework inside Visual Studio?
What do I have to do to select Android 8.1 as the Target Framework inside Visual Studio?
In your VS, Tools->Android->Android SDK Manager, you will see Android SDK for VS, it default path is C:\Program Files (x86)\Android\android-sdk.
In your AS, Android SDK's path is C:\Users\user name\AppData\Local\Android\Sdk
Now, you can change the VS's Android SDK's path to C:\Users\user name\AppData\Local\Android\Sdk, but we don't suggest you do that, it may cause VS compilation errors at some point, and by then you cannot find the cause of the problem.
So, you can download the Android 8 from VS again.

Resources