简体   繁体   中英

Xamarin Android axml Designer, System.ArgumentNullException: Value cannot be null

Note: This occurs with the most recent version of Visual Studio Mac and the latest Xamarin tools installed.

I started to work on an older Xamarin Android project that I've been maintaining over the past few years. It's been a long time since I've made any UI changes to the application and there was a minor adjustment I needed to make in order to add some additional information to the screen. I opened up the axml layout of screen I needed to modify. When doing so, the designer view displayed the following error:

System.ArgumentNullException: Value cannot be null. Parameter name: path1 at System.IO.Path.Combine (System.String path1, System.String path2, System.String path3) [0x0002a] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/Path.cs:849 at Xamarin.AndroidDesigner.DesignerProject+<>c.b__118_0 (System.String l) [0x00000] in /Users/vsts/agent/2.126.0/work/1/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerProject.cs:532 at System.Linq.Enumerable+SelectListIterator 2[TSource,TResult].MoveNext () [0x00036] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/Select.cs:365 at System.Linq.Enumerable+WhereEnumerableIterator 1[TSource].MoveNext () [0x0004e] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/Where.cs:146 at System.Linq.Enumerable+SelectManySingleSelectorIterator 2[TSource,TResult].ToList () [0x0002d] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/SelectMany.cs:257 at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable 2[TSource,TResult].ToList () [0x0002d] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/SelectMany.cs:257 at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable 1[T] source) [0x00015] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/ToCollection.cs:30 at Xamarin.AndroidDesigner.DesignerProject.GetLibraryProjectThemes () [0x00037] in /Users/vsts/agent/2.126.0/work/1/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerProject.cs:531 at Xamarin.AndroidDesigner.DesignerProject.GetIsProjectTheme (System.String themeName) [0x0000e] in /Users/vsts/agent/2.126.0/work/1/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerProject.cs:544 at Xamarin.AndroidDesigner.DesignerSessionParams.GetData (Xamarin.AndroidDesigner.AndroidDesignerSession session, Xamarin.AndroidDesigner. AndroidRenderSession renderer) [0x00154] in /Users/vsts/agent/2.126.0/work/1/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/DesignerSessionParams.cs:209 at Xamarin.AndroidDesigner.AndroidRenderSession+d__115.MoveNext () [0x00224] in /Users/vsts/agent/2.126.0/work/1/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/AndroidRenderSession.cs:783

I initially thought there must be some kind of Syntax issue with the newer Xamarin tools but when I tried creating a brand new Android Layout, I received the same error for the designer. The Xamarin Android new layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Because of this, I'm thinking that there has to be some kind of setup option that I'm missing due to this being an older project. Perhaps something to do with the incorrect designer tool path being assigned somewhere? Has anyone come across this error or have some ideas on what to check?

Edit: Additional Info Android SDK Location:

/Users/mrnope/Library/Developer/Xamarin/android-sdk-macosx

Android NDK Location:

/Users/mrnope/Library/Developer/Xamarin/android-ndk/android-ndk-r14b

Java SDK (JDK) Location:

/usr

找到的文件 Android SDK Tools: Android SDK工具 SDK Platforms: SDK平台

It's most likely that Visual Studio cannot find the proper Android SDK path and/or the Platform Tools.

Tools -> Option -> Android Settings

And insert the proper path there, then I would double-check that the Platform Tools are installed correctly and are on the same version of the SDK.

Tools -> Android -> Android SDK Manager

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM