'Resource' does not contain a definition for 'Xml'

Following the Android PreferenceFragmetCompat docs (developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat) I added a folder to my Resources folder in my Xamarin.Android project. Then I added a new .xml file to that folder, called preferences.xml.

Here are the contents of that file:

<PreferenceScreen
xmlns:android="(correct schema, new to the forum)">
    <CheckBoxPreference
          android:key="pref_autosync"
          android:title="@string/pref_autosync"
          android:summary="@string/pref_autosync_summary" />
</PreferenceScreen>

Both strings are properly defined in the strings.xml file.

I went on to add a PreferenceFragmentCompat to my project, in which, in the overriden method OnCreatePreferences I added the following line:

SetPreferencesFromResource(Resource.Xml.preferences);

The error states 'Resource' does not contain a definiton for 'Xml'..

I tried:

  • Cleaning and rebuilding my project
  • Restartng Visual Studio
  • Restarting my computer
  • Deleting the contents of both the bin and obj folders, cleaning and rebuilding
  • Changing the CustomTool property of the preferences.xml file to MSBuild:UpdateGeneratedFiles and rebuilding
  • Screaming with frustration

I am aware that this SO thread (stackoverflow.com/questions/33219973/resource-contains-no-definition-for-animation/33228113#33228113) exists, and I tried all the solutions mentioned there. Nothing seems to help.

Thank you in advance for any help.

Also posted to StackOverflow here: stackoverflow.com/questions/51553463/resource-does-not-contain-a-definition-for-xml

Best Answer

Answers

  • Tored_Tored_ Member
    I solved it, thanks for reminding me to check it here :)
Sign In or Register to comment.