Error: unexpected element <receiver> found in <manifest>

stesvisstesvis USMember ✭✭✭
edited October 9 in Xamarin.Forms

Suddenly I get this build error in VS 2019 but not in VS 2017 when I build my Android project:
unexpected element <receiver> found in <manifest>

And this is what those lines look like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.0.26" android:versionCode="148" package="ca.levitica.livedispatch.staging" android:installLocation="auto">
  <!-- Other stuff -->
  <receiver android:name=".BootReceiver" android:enabled="true">
    <intent-filter>
      <action android:name="android.intent.action.BOOT_COMPLETED"></action>
    </intent-filter>
  </receiver>
  <!-- Other stuff -->
</manifest>

What can I do? Thanks!

Best Answer

Answers

  • PatrickSlotPatrickSlot USMember

    Is the receiver element inside the application element?

  • IanCarrollIanCarroll Member

    I have the same issue.

    Visual studio is putting the code in itself. The bottom of the manifest file looks like this. The error being on line 81.














    When I remove the whole receiver block VS2019 puts it back in.
    I have tried moving it inside the but again VS2019 moves it back outside.

    Don't want to have to go back to VS2017.

  • stesvisstesvis USMember ✭✭✭
    > @PatrickSlot said:
    > Is the receiver element inside the application element?

    No it was not. I will try to move it manually like @DarrenS said and try! Thank you!
  • stesvisstesvis USMember ✭✭✭

    @PatrickSlot and @DarrenS you are both right, moving that element allows me to compile now.
    Thank you!

  • joaoeopjoaoeop Member

    @DarrenS said:
    I had the same problem. Was fine with VS2017. Failed with latest VS2019.

    The error is reported for the file \App\App.Android\obj\Debug\90\android\manifest\AndroidManifest.xml

    However, to fix the problem I had to edit the file \App\App.Android\Properties\AndroidManifest.xml

    The solution was to move the receiver nodes to inside the application node.

    Was:









    Changed to:










    Did you managed to solve this?

    Everytime you rebuild you have to fix it manually but then you cant test the app.

  • joaoeopjoaoeop Member

    Answering my own question:
    Go to the android project properties, select Android Options and uncheck "Use incremental Android packaging system (aapt2)".
    Or open the project .csproj file and change the AndroidUseAapt2 xml tag to false.

Sign In or Register to comment.