I use the phonegap media plugin for playing a mp3 livestream.
The media plugin requires a lot of permissions by default.
Can i run this plugin with less permissions? I only need internet connection.
When i set no permissions in the config.xml Phonegap Build automatically overwrite that rule and set all permissions.
Or can i edit the config of the plugin? Or edit the permissions after build?
thank you
The media plugin requires a lot of permissions by default.
Can i run this plugin with less permissions? I only need internet connection.
When i set no permissions in the config.xml Phonegap Build automatically overwrite that rule and set all permissions.
Or can i edit the config of the plugin? Or edit the permissions after build?
thank you
- 5 Posts
- 1 Reply Like
- sad
Posted 6 years ago
John Weidner, Champion
- 435 Posts
- 80 Reply Likes
You can selectively remove android permissions that a plugin might add by adding code like the following to your config.xml:
I use the media plugin just for playing sounds. I use the above configuration to remove the four permissions that the media plugin adds that are not necessary for my app since I'm only playing audio.
<gap:config-file platform="android" parent="/manifest" mode="delete">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</gap:config-file>
I use the media plugin just for playing sounds. I use the above configuration to remove the four permissions that the media plugin adds that are not necessary for my app since I'm only playing audio.
- 5 Posts
- 1 Reply Like
Awesome! Spended days for a solution like this!
Very thanks! Works perfect!
Very thanks! Works perfect!
- 7 Posts
- 0 Reply Likes
John, I've placed your code in my config and keep getting a malformed config error when uploading to pgb. Any ideas?
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Perhaps a typo.
You can validate your config.xml online at W3C's XML validator. It will show you the error(s).
You can validate your config.xml online at W3C's XML validator. It will show you the error(s).
John Weidner, Champion
- 435 Posts
- 80 Reply Likes
Make sure that you also have
xmlns:gap = "http://phonegap.com/ns/1.0" specified in your widget element at the top of your config.xml file.- 7 Posts
- 0 Reply Likes
That code is there and I also validated my xml with no errors. I've tried the code both in and out of the widget, but get errors with both.
(Edited)
- 7 Posts
- 0 Reply Likes
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
How can you have validated with no errors? The namespace for android: is missing.
- 7 Posts
- 0 Reply Likes
I meant that the XML in general was validated with no obvious errors using W3C's validator. Sorry for the confusion.
But you are right. Not having the namespace for android was the cause of the problem. Thanks a ton.
But you are right. Not having the namespace for android was the cause of the problem. Thanks a ton.
- 1 Post
- 0 Reply Likes
- 1 Post
- 0 Reply Likes
John, you missed declare this namespace in the first line xmlns:android="http://schemas.android.com/apk/res/an..."
- 5 Posts
- 0 Reply Likes
I got my app to build with no issues with all recommendations above - but the pesky media plugin permissions are still in the platforms/android/AndroidManifest.xml. I have succeeded in removing them by unpacking the APK, modifying AndroidManifest.xml and rebuilding but this is a pain for the workflow. Is there any reason why the permissions linger on? Does it have something to do with the "Manifest merger disabled. Using project manifest only." statement during the phonegap app build? Any help would be greatly appreciated...!
John Weidner, Champion
- 435 Posts
- 80 Reply Likes
- 5 Posts
- 0 Reply Likes
Thanks john - command line of course ;)
John Weidner, Champion
- 435 Posts
- 80 Reply Likes
This forum is for "PhoneGap Build" which is Adobe's cloud based service. I think that would explain why the gap:config-file item wasn't working for you.
- 25 Posts
- 0 Reply Likes
Hi,
Thanks for this. It's very helpful.
I found, I think, that for this to work to remove permissions added by a plug-in, the code that you are adding to the config.xml must come somewhere after the line that adds the plugin. Otherwise, it doesn't seem to work (which sounds like it makes sense if PGB is following the config.xml sequentially).
I am looking for a slightly different variation. I want to change the permissions to optional (the plugin adds it as required). I am able to remove it, using
But if I add it back using:
I get it back as required, not optional. I'm thinking my syntax is incorrect for the "required" parameter?
Again, thanks.
Scott
Thanks for this. It's very helpful.
I found, I think, that for this to work to remove permissions added by a plug-in, the code that you are adding to the config.xml must come somewhere after the line that adds the plugin. Otherwise, it doesn't seem to work (which sounds like it makes sense if PGB is following the config.xml sequentially).
I am looking for a slightly different variation. I want to change the permissions to optional (the plugin adds it as required). I am able to remove it, using
But if I add it back using:
I get it back as required, not optional. I'm thinking my syntax is incorrect for the "required" parameter?
Again, thanks.
Scott
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers
-
Plugins
- 1283 Conversations
- 38 Followers







