locked
unexpected element <intent-filter> found in <manifest> RRS feed

  • Question

  • User138021 posted

    I moved my app from VS 2017 to VS 2019 and receive the error,

    Severity Code Description Project File Line Suppression State Error unexpected element found in . AndroidRadio1b \AndroidRadio1b\obj\Debug\44\android\manifest\AndroidManifest.xml 11

    My manifest file looks like

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="AndroidRadio_1b.AndroidRadio_1b" android:versionCode="11" android:installLocation="preferExternal" android:versionName="11">
      <uses-feature android:name="android.hardware.usb.host" />
      <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
      <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      <application android:label="DataFM Radio" android:icon="@drawable/icon" android:name="android.app.Application" android:allowBackup="true" android:debuggable="true">
        <intent-filter>
          PROBLEM LINE--><action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
          <uses-permission android:name="android.permission.INTERNET" />
        </intent-filter>
        <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" />
        <activity android:label="AddPage" android:name="md5c0f61809ef45a589d091ca5d900d87b7.AddPage" />
        <activity android:label="AmpPage" android:name="md5c0f61809ef45a589d091ca5d900d87b7.AmpPage" />
        <activity android:label="DataAd" android:name="md5c0f61809ef45a589d091ca5d900d87b7.DataAd" />
        <activity android:label="DataPage" android:name="md5c0f61809ef45a589d091ca5d900d87b7.DataPage" />
        <activity android:label="EmailSetup" android:name="md5c0f61809ef45a589d091ca5d900d87b7.EmailSetup" />
        <activity android:label="IPNetwork" android:name="md5c0f61809ef45a589d091ca5d900d87b7.IPNetwork" />
        <activity android:icon="@drawable/icon" android:label="AndroidRadio_1b" android:name="md5c0f61809ef45a589d091ca5d900d87b7.MainActivity">
          <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
          <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/accessory_filter" />
          <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
          </intent-filter>
        </activity>
        <activity android:label="MessagePage" android:name="md5c0f61809ef45a589d091ca5d900d87b7.MessagePage" />
        <activity android:label="messageview" android:name="md5c0f61809ef45a589d091ca5d900d87b7.messageview" />
        <activity android:label="UnitSetup" android:name="md5c0f61809ef45a589d091ca5d900d87b7.UnitSetup" />
        <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999999" android:authorities="AndroidRadio_1b.AndroidRadio_1b.mono.MonoRuntimeProvider.__mono_init__" />
        <!--suppress ExportedReceiver-->
        <receiver android:name="mono.android.Seppuku">
          <intent-filter>
            <action android:name="mono.android.intent.action.SEPPUKU" />
            <category android:name="mono.android.intent.category.SEPPUKU.AndroidRadio_1b.AndroidRadio_1b" />
          </intent-filter>
        </receiver>
      </application>
    </manifest>
    

    The line that it says is causing the problem is denoted above. I've looked at a bunch of problems but on the forums but none help.

    Thursday, November 7, 2019 5:43 PM

All replies

  • User2148 posted

    try to add your intent filter in MainActivity.cs https://docs.microsoft.com/it-it/xamarin/android/platform/android-manifest#intent-actions-and-features

    Thursday, November 7, 2019 5:49 PM
  • User138021 posted

    I have the following in my MainActivity.cs

     [Activity(Label = "AndroidRadio_1b", MainLauncher = true, Icon = "@drawable/icon")]
        [IntentFilter(new[] { UsbManager.ActionUsbDeviceAttached })]
        [MetaData(UsbManager.ActionUsbDeviceAttached, Resource = "@xml/accessory_filter")]
    

    Is anything else required? This has always been in, and I'm still receiving the error.

    Thursday, November 7, 2019 10:38 PM
  • User382871 posted

    What's the version of nuget packges? Try to update the package to latest stable version. And then delete the content in obj and bin folder. If this not work, create a new project then move the code to the new sample.

    Friday, November 8, 2019 6:59 AM
  • User138021 posted

    I updated the nuget packages, one needed to be updated, and removed the oby and bin contents. Recompiled same error.

    Out of desperation I took the project back in a separate folder and opened it in Visual Studio 2017. Everything worked perfectly. Would still like to get it working in 2019 but at least I can function while I'm working on the problem.

    This is a big project, I don't believe moving code to a new project is a possibility.

    Monday, November 11, 2019 2:51 PM
  • User382871 posted

    The <intent-filter> should be used in a <activity> tag. And if you have add these settings in MainActivity.cs, delete the part content in Manifest.xml and try again.

    Tuesday, November 12, 2019 8:12 AM