question

ReganSean-6398 avatar image
1 Vote"
ReganSean-6398 asked RobCaplan edited

Android SDK constantly tries to repair

I am building a Xamarin project for android devices and I want to use an emulator to run and test the application.

I have it set up correctly on another laptop and the emulator and project runs fine. Yet trying to set it up on my new PC is giving me problems. Everytime I go into the android SDK Manager it tells me to repair "Android Emulator", "Android SDK Build-Tools 30.0.2" and "Android SDK Platform 30". I have tried to repair it countless times, updated my VS 2019, uninstalled Xamarin and reinstalled it, matched the SDKs and settings from my other computer, all with no luck.

I also get this error from time to time.

System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.Combine(String path1, String path2)
at Xamarin.Android.Tools.ProcessUtils.<FindExecutablesInDirectory>d__9.MoveNext() in /Users/builder/azdo/work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/ProcessUtils.cs:line 177
at Xamarin.Android.Tools.ProcessUtils.<FindExecutablesInPath>d
_8.MoveNext() in /Users/builder/azdo/work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/ProcessUtils.cs:line 168
at Xamarin.Android.Tools.AndroidSdkBase.<GetAllAvailableAndroidNdks>d
_73.MoveNext() in /Users/builder/azdo/work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:line 153
at Xamarin.Android.Tools.AndroidSdkWindows.<GetAllAvailableAndroidNdks>d
_43.MoveNext() in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkWindows.cs:line 257
at Xamarin.Android.Tools.AndroidSdkBase.GetValidNdkPath(String ctorParam) in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:line 128
at Xamarin.Android.Tools.AndroidSdkBase.Initialize(String androidSdkPath, String androidNdkPath, String javaSdkPath) in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs:line 71
at Xamarin.Android.Tools.AndroidSdkWindows.Initialize(String androidSdkPath, String androidNdkPath, String javaSdkPath) in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkWindows.cs:line 310
at Xamarin.Android.Tools.AndroidSdkInfo..ctor(Action`2 logger, String androidSdkPath, String androidNdkPath, String javaSdkPath) in /Users/builder/azdo/_work/278/s/xamarin-android/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/AndroidSdkInfo.cs:line 18
at Xamarin.Android.Tasks.MonoAndroidHelper.RefreshAndroidSdk(String sdkPath, String ndkPath, String javaPath, TaskLoggingHelper logHelper)
at Xamarin.Android.Tasks.ResolveSdks.RunTask()
at Xamarin.Android.Tasks.AndroidTask.Execute() EI.ManagementApp.Android

Any help is appreciated.

dotnet-xamarin
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ReganSean-6398 , you can try to set the sdk location to a simple and short path.

0 Votes 0 ·

Hi @JessieZhang-2116 , I tried moving it to C:/android-sdk and updating the path in VS 2019 but had no success

0 Votes 0 ·

I re-installed vs2019 still having same error.
also installed NDK, I checked that downloaded 1GB NDK is stored in Temp folder "C:\Users\Admin\AppData\Local\Temp\xamarin-android-sdk", don't know why it is storing in Temp folder.
Please suggest solution if any one resolved this.


1 Vote 1 ·
Show more comments

1 Answer

SunilParmar-8035 avatar image
3 Votes"
SunilParmar-8035 answered imranaftabrana commented

@ReganSean-6398
I solved this issue, following is the steps.
1. You need to install ndk if not installed.
2. open .csproj file of Droid project.
3. Add <AndroidNdkDirectory>path of ndk-bundle</AndroidNdkDirectory> in First <PropertyGroup> tag.
for example : <AndroidNdkDirectory>C:\Program Files (x86)\Android\android-sdk\ndk-bundle</AndroidNdkDirectory>
4. Save and Rebuild project.

Please reply if above solution worked for you or not.

Following is the reference links :
https://github.com/xamarin/xamarin-android/issues/2673

https://developercommunity.visualstudio.com/t/visual-studio2019-ndk-location-path-is-missing-in/439101

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks that worked perfectly, I can get the emulator running now

0 Votes 0 ·

Thanks, works perfectly for me.

0 Votes 0 ·