Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

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

stesvisstesvis USMember ✭✭✭✭
edited October 2019 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?

  • 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.

  • Pedro_PazPedro_Paz Member ✭✭

    @joaoeop said:
    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.

    Worked like a charm. Thanks

  • DelwarDelwar USMember ✭✭

    Hi, I need to upgrade from Android 9 to Android 10 as per google play requirement for which I had to upgrade from Visual Studio 2017 to 2019. My project compiles fine in 2017 but fails in 2019 with following error. Your help will be greatly appreciated.

    Even if I move into application yet I've the second error. I tried removing that more manifest code file but it comes back every time I try recompiling.

    Errors:
    unexpected element found in
    unexpected element found in

    Here is the manifest:
    <?xml version="1.0" encoding="utf-8"?>

















Sign In or Register to comment.