Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected element <uses-library> found in manifest

I am using org.apache.legacy library in my xamarin project. I have added <uses-library> tag in my manifest file but I get an error while building the project which says:

Unexpected element <uses-library> found in manifest.

Also when I try to comment that line, it comes back while building the solution.

like image 977
M Salman Avatar asked Oct 10 '19 09:10

M Salman


3 Answers

uses-library tags should be placed within the application element, that's why you get the error.

the problem with the compiler complaining about the same line even if you change it can most likely be solved by restarting Xamarin studio, and then cleaning the project and rebuilding.

like image 183
Joachim Haglund Avatar answered Oct 22 '22 04:10

Joachim Haglund


Ok, so one of my co workers found the solution to this, but it's weird. So, for context we use Visual Studio for Mac so this might not be 100% compatible with Windows. The issue we found was that Visual Studio has several different views for the AndroidManifest.xml file and one of the views was modified at some point in the past.

  • The default view is the UI based one with inputs and what not to help working with the file.
  • The second view is when you right click the manifest file and use OpenWith -> 'Source Code editor'. This view is a minimalistic view of the manifest in xml that can be edited. In here you should also find the problem line about the apache library that is not in the application tag as it should be. So, you can remove it here.
  • The third view is the generated manifest and can be found by following the error messages outputted by the IDE about the uses-library tag.

Manifest UI View -> Manifest intermediate xml view -> Manifest generated file

It seems that you can only modify one version of the manifest file in xml since the other will always overwrite your changes. By following the error message you only get to the final output and not the intermediary Manifest that can actually be edited and maintain its changes. There was a modification to the manifest a long time ago in our project that is just now throwing errors with the newest release of Visual Studio.

The suggested fix is to not follow the error message to open the Manifest and instead open the manifest file in xml raw. It will be a smaller file than the generated one so look for that to know you're in the right place. Remove the uses-library line that is incorrectly placed outside of the Application tag and save. Hope this helps somebody else cause it definitely caught me up for a few hours.

like image 5
cmw2379 Avatar answered Oct 22 '22 05:10

cmw2379


So after spending few nights on this stupid bug, I created a whole new app from scratch and configured/installed all the packages and SDKs for using Google Maps in Xamarin android native and this time I put the tag inside the application tag and installed the app on my device and it worked absolutely fine. Hope it helps !! Cheers !!

like image 4
M Salman Avatar answered Oct 22 '22 05:10

M Salman