Visual Studio 2015 unable to find Android API Leve

2019-09-03 20:13发布

问题:

When I'm trying to create Xamarin Forms project, VS gives me the following error for Android project:

Object reference not set to an instance of an object.

The output is:

[I:sdk]: Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found: Path contains adb.exe in \platform-tools (C:\Program Files (x86)\Android\android-sdk).

[I:sdk]: Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found: Path contains ndk-stack.exe in . (C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e).

[I:sdk]: Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory found: Path contains jarsigner.exe in \bin (C:\Program Files (x86)\Java\jdk1.7.0_51).

[I:Unknown]: Found Android SDK. API levels: (none)

I think the issue is because of the last line, API levels: (none). This picture shows SDK Manager, and that I have installed API 23.

Any troubleshooting tip is welcome!

UPDATE

If I try to build existing projects, I'll get the following exceptions:

"No Android platforms installed at '{0}'. Please install an SDK Platform with the {1}{2}tools{2}{3} program."

Could not determine $(TargetFrameworkVersion) for API level '-2147483648.' App1

And this is the output:

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA5300: "No Android platforms installed at '{0}'. Please install an SDK Platform with the {1}{2}tools{2}{3} program."

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA5300: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA5300: at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA5300: at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA5300: at System.String.Format(IFormatProvider provider, String format, Object[] args)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA5300: at Microsoft.Build.Framework.LazyFormattedBuildEventArgs.FormatString(CultureInfo culture, String unformatted, Object[] args)

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(569,2): error XA0000: Could not determine $(TargetFrameworkVersion) for API level '-2147483648.'

Does anyone know what are {0..3} placeholders?

回答1:

Only installing latest Xamarin solved the problem.

I've tried installing SDK and NDK with Visual Studio installer, or upgrading Platform API, and reinstalling everything, and none of them worked. Including this answer.