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!
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:
<application android:label="App"></application> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>
Changed to:
<application android:label="App"> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" /> <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>
Answers
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.
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:
> 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!
@PatrickSlot and @DarrenS you are both right, moving that element allows me to compile now.
Thank you!
Did you managed to solve this?
Everytime you rebuild you have to fix it manually but then you cant test the app.
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
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"?>