Our 3rd party Android library's manifest declares uses-permission entries for android.permission.BLUETOOTH and android.permission.BLUETOOTH_ADMIN, but our app does not use those bluetooth capabilities. As a result, our users see these app permissions during installation from GooglePlay, which creates confusion.
I have tried using the manifest merging approach by adding these lines to our app's manifest:
<uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove" />
However, it does not change what appears in the permissions list during app installation from Google Play.
Then I discovered @xakpc 's post saying that Xamarin does not support manifest merging. I see bug 24809, but it is marked as resolved.
If this issue is still outstanding, then I suspect that I would need to implement something like what @AlexanderMelchers did in this post.
Do I have this right? Please tell me it's much simpler than this!
Answers
Any update @PhilipHadley ?
@stepheaw
Update from Microsoft on 10/23:
I’ve spoken with one of the Xamarin.Android developers, and we did confirm the same behavior you are seeing. MSBuild does not appear to accept modified manifest elements, and reverts the change. The workaround you found in the forum post does seem to be the best way to correct this, although it is not desired.
Due to the complexity of the workaround and the low priority/severity of the bug, our team opted not to fix, for now. I have requested to be notified when a fix is available, so I will provide another update when that happens.
@PhilipHadley
I believe the closer item would be this feature:
https://bugzilla.xamarin.com/show_bug.cgi?id=52857
I highly recommend reporting a new feature request in our github repo and backlink to this bug:
https://github.com/xamarin/xamarin-android/issues
Any update ?
@oguzhanorhaan
I have not been notified of any fix for this.
I see that this feature request was submitted: https://github.com/xamarin/xamarin-android/issues/1335
Ended up with the solution below to remove 3rd party permissions.
In the .csproj file, add the following:
And here's the
android-manifest-tools-remove-permissions.xsl
which is used in theXslTransformation
taskThis will work in the same way android manifest merge works, for example:
@AyhamFakihani When i add the
tools:node="remove"
i can build as i get aerror XAGAP7000: System.Xml.XmlException: 'tools' is an undeclared prefix
. Any help? Your workaround sounds great, as it automates having to manually delete the permission. In my case i need it to remove a duplicate permission that cancels mine out.Edit: Nvm, i saw the tools url, but i still cant get it to work with that as i have a service tag i need removed, not a uses-permission. Will try to edit to see if it works.
I ended up doing a similar solution to @mayhammf is that im using a python script set in the Android csproj options under 'Custom Command', i add a new command set "After Build". i set the command as so python remove.py ${ProjectConfig}
The script is as follows:
import os
import sys
path = "./obj/" + sys.argv[1] + "/android/"
print 'Manifest Path:',path
os.rename(path + "AndroidManifest.xml", path + "AndroidManifestOld.xml")
remove = "manifest tag to remove"
with open(path + 'AndroidManifestOld.xml') as oldfile, open(path + 'AndroidManifest.xml', 'w') as newfile:
for line in oldfile:
if (remove not in line):
newfile.write(line)
os.remove(path + "AndroidManifestOld.xml")
it simply removes the line that you dont need, in my case it was an extra service tag from a 3rd party library.
I managed to get @AyhamFakihani version working, however it would remove all the tags with the same name, including the one i set and need. My route just removes the exact line.
@AyhamFakihani
If I add xmlns:tools="http://schemas.android.com/tools" to the manifest section of my AndroidManifest.xml, I get errors in styles.xml