cordova – phonegap build permissions in android-ThrowExceptions

Exception or error:

I’m using phonegap build to create my app.

Is there a way I can configure the permissions asked by android?

For now it asks for all the permissions when I actually only need internet, localstorage and notifications.

Please bare in mind – I’m only using phonegap build, Not CLI and not Cordova.
I have no AndroidManifest.xml only config.xml

Can anybody help?

Thanks.

Edit:

This was answered by SvenT23.

We both realized that phonegap has removed this answer from their current docs and left it only in the old docs.

For future reference I’m adding the instructions from phonegap in case it will get deleted in the future.

API Features

Currently supported through this interface are the following feature names:

http://api.phonegap.com/1.0/battery
// maps to android:BROADCAST_STICKY permission

http://api.phonegap.com/1.0/camera
// maps to android:CAMERA, winphone:ID_CAP_ISV_CAMERA, and winphone:ID_HW_FRONTCAMERA permissions

http://api.phonegap.com/1.0/contacts
// maps to android:READ_CONTACTS, android:WRITE_CONTACTS, android:GET_ACCOUNTS, and winphone:ID_CAP_CONTACTS permissions

http://api.phonegap.com/1.0/file
// maps to WRITE_EXTERNAL_STORAGE permission

http://api.phonegap.com/1.0/geolocation
// maps to android:ACCESS_COARSE_LOCATION, android:ACCESS_FINE_LOCATION, android:ACCESS_LOCATION_EXTRA_COMMANDS, and winphone:ID_CAP_LOCATION permissions

http://api.phonegap.com/1.0/media
// maps to android:RECORD_AUDIO, android:RECORD_VIDEO, android:MODIFY_AUDIO_SETTINGS, and winphone:ID_CAP_MICROPHONE permissions

http://api.phonegap.com/1.0/network
// maps to android:ACCESS_NETWORK_STATE, and winphone:ID_CAP_NETWORKING permissions

http://api.phonegap.com/1.0/notification
// maps to VIBRATE permission

http://api.phonegap.com/1.0/device
// maps to winphone:ID_CAP_IDENTITY_DEVICE permission

Example Usage

<?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns   = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = "com.phonegap.example"
        versionCode = "10" 
        version     = "1.0.0" >

    <!-- versionCode is optional and Android only -->

    <name>PhoneGap Example</name>

    <description>
        An example for phonegap build docs. 
    </description>

    <author href="https://build.phonegap.com" email="support@phonegap.com">
        Hardeep Shoker 
    </author>

    <!--
      If you do not want any permissions to be added to your app, add the
      following tag to your config.xml; you will still have the INTERNET
      permission on your app, which PhoneGap requires.
    -->
    <preference name="permissions" value="none"/>

    <!-- to enable individual permissions use the following examples -->
    <feature name="http://api.phonegap.com/1.0/battery"/>
    <feature name="http://api.phonegap.com/1.0/camera"/>
    <feature name="http://api.phonegap.com/1.0/contacts"/>
    <feature name="http://api.phonegap.com/1.0/file"/>
    <feature name="http://api.phonegap.com/1.0/geolocation"/>
    <feature name="http://api.phonegap.com/1.0/media"/>
    <feature name="http://api.phonegap.com/1.0/network"/>
    <feature name="http://api.phonegap.com/1.0/notification"/>
</widget>
How to solve:

A quick bit of googling returns the <feature> element to set permissions. Combined with <preference name="permissions" value="none"/> it should be exactly what you’re looking for.

http://docs.phonegap.com/phonegap-build/configuring/#Features

Leave a Reply

Your email address will not be published. Required fields are marked *