- Download AXMLPrinter2.jar from https://code.google.com/archive/p/android4me/downloads
- Build your solution and create an archive (.apk) by selecting Build->Archive...
- After archiving is done, open folder and find the archived *.apk, open the archive (for example using 7Zip) and extract/unzip AndroidManifest.xml
- Open any text editor and type: start cmd.exe /c "java -jar AXMLPrinter2.jar AndroidManifest.xml > AndroidManifest.plaintext.xml" and save it as a *.bat file in the same directory
- Run the *.bat file and check the resulting AndroidManifest.plaintext.xml file. This is the file we will be editing using a shell script
- Create the shell script you need. It should target obj$configuration\android\AndroidManifest.xml for example: (Get-Content 'obj\Release*\android\AndroidManifest.xml').replace('', '') | Set-Content 'obj\Release*\android\AndroidManifest.xml' the RemoveAndroidPermission.ps1 script above finds READ_EXTERNAL_STORAGE permission and removes it
- Save your scrip into your solution directory
- Open your project file *.csproj in any text editor. Scroll to the bottom, and a new custom tag to execute your script: In my case for exaple:
- Save the changes to *.csproj and try rebuilding your solution. If it fails, you either did something wrong or your script corupts the AndroidManifest.xml
- After building succeeds, see that the changes to obj$configuration\android\AndroidManifest.xml were made successfully
- Repeate steps 2-5, in other words make and archive, extract AndroidManifest.xml, use AXMLPrinter2 and see that the changes were successful
- You are done! ;)
Last active
June 12, 2019 09:32
-
-
Save Guiorgy/75e9f9a0acb47fba96bc4eea537f0143 to your computer and use it in GitHub Desktop.
Currently (11/1/19) Xamarin does not support merging manifest, or having different manifests for different build configurations. This is a workaround originally found by AlexanderMelchers at https://forums.xamarin.com/discussion/97461/android-manifest-file-merge-rules
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my case, for example, I had several build configurations, some of which required READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions, but others did not.