Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add "uses-permissions" tags to AndroidManifest.xml for a Cordova project?

Some <uses-permission> entries are added automatically to AndroidManifest.xml, based on cordova plugins that you add. However, I need the <uses-permission android:name="android.permission.INTERNET" /> permission, which isn't added automatically.

I can add that directly to AndroidManifest.xml, but it will get overwritten the next time I run cordova build, and I don't want to have to keep re-adding it...

I'm sure there's a "Cordova" way of specifying permissions (in config.xml, or elsewhere), but I'm not seeing it in their documentation anywhere...

So, what is the "Cordova way" of specifying user permissions?

like image 989
Troy Avatar asked May 05 '15 00:05

Troy


People also ask

How do you add use permissions in config XML?

You need to add xmlns:android="http://schemas.android.com/apk/res/android" to the root widget tag in config. xml.

What is permission tag in manifest file?

contained in: <manifest> description: Declares a security permission that can be used to limit access to specific components or features of this or other applications. See the Permissions section in the introduction, and the Security and Permissions document for more information on how permissions work.


1 Answers

As I know AndroidManifest.xml will not be generated every time when you run cordova build. When you add/remove a plugin it will be modified accordingly. But if you add your own permissions it will not be removed(Unless there is a conflict).

Since the permissions are Android (platform) specific, in your case you have to add it into the AndroidManifest.xml file only.

Even in plugin.xml of any plugin they add permission as shown :

<platform name="android">     <config-file target="AndroidManifest.xml" parent="/manifest">         <uses-permission android:name="android.permission.INTERNET"/>     </config-file> </platform> 

Which says add uses-permission line to AndroidManifest.xml file at the installation time of plugin. But you cant mention this in config.xml file.

Also don't forget to put this attribute in the root widget element present in the config.xml file,located in the root folder of the app, as @hiddentao said in a comment.

config.xml

<widget   xmlns:android="http://schemas.android.com/apk/res/android"   ...> 
like image 85
kumar Avatar answered Sep 30 '22 01:09

kumar