Unexpected element <uses-library> when releasing

For some time now I cannot release anymore the Android version of my app. Using latest stable versions of everything, targeting Android 9.0 but when I build, it fails with:

unexpected element <uses-library> found in <manifest>. (APT0000)

My AndroidManifest.xml keeps getting extended with

<uses-library android:name="com.google.android.maps" />

although I'm not using any Google Maps in my app. Must be related to some other dependency but there so many of them when it comes to an Android app, that's hard to keep track of why everything is needed.

Any idea for this build error?

Best Answer

  • XavierPerseguersXavierPerseguers CH ✭✭✭
    Accepted Answer

    Strange, I tried to manually remove again that offending line from AndroidManifest.xml and this time it did not get added back while building.


  • albertoha94albertoha94 Member ✭✭
    edited October 11

    Have you checked if a NUGET package requires something related to maps?
    Maybe that package is adding the reference.

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭

    @albertoha94 Yes, for sure, but have a look at this mess:

    None of these references are actually required by me, but they are there for some reason for Xamarin.Forms and alike. That's really unfortunate, will have to investigate but for Xamarin.iOS I have +/- only what I actually need as 3rd-party components. for Xamarin.Android I have a bunch of such packages which I have no idea what they really do.

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭
    edited October 14

    I created a graph of dependencies for those Xamarin.Android libraries:

    This helped me removing 3 useless dependencies:

    • Xamarin.Android.Support.Exif
    • Xamarin.Android.Support.v7.MediaRouter
    • Xamarin.Android.Support.v7.Palette

    However the problem remains!

  • XavierPerseguersXavierPerseguers CHMember ✭✭✭
    Accepted Answer

    Strange, I tried to manually remove again that offending line from AndroidManifest.xml and this time it did not get added back while building.

  • albertoha94albertoha94 Member ✭✭


  • slink99slink99 Member ✭✭
    edited October 28

    I am having the same result, except it seems to be tied to GoogleAds/AdMob. I am getting

    <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />

    placed above and the same line is inside of activity with android:exported="False" I have tried removing NuGet packages, installing packages that seemed to be missing, removing lines, cleaning, rebuilding and it always comes back with the same lines in the same place. Any suggestions for additional moves to make?

  • slink99slink99 Member ✭✭

    This is still not solved, but there was one issue that may help others. VS had decided to include the dll file as a reference, which created hundreds of conflict warnings. Clearing that out eliminated those. Still working on the dependencies list and adding files indicated. It is odd that compilation and execution worked fine for iOS without these.

  • slink99slink99 Member ✭✭

    It is looking like this may be fixed by following the Aapt2 instructions about halfway down the page https://docs.microsoft.com/en-us/xamarin/android/release-notes/10/10.0#aapt2-enabled-by-default-for-all-projects

Sign In or Register to comment.