solimanware
solimanware

Reputation: 3052

Phonegap Android permissions

I have a Phonegap app that I'm currently developing and testing for Android. Problem is, when I publish to device, the Android Manifest is full of permission requests that I did not ask for.

I tried adding:

<preference name="permissions" value="none" />

to config.xml but it still doesn't work.

How can I only let "Network permission" only?

Upvotes: 1

Views: 3467

Answers (2)

John Weidner
John Weidner

Reputation: 2165

If you are using PhoneGap Build (not the command line tools) and some plugin is adding permissions that you know your app does not need, you can remove those permissions by adding lines to your config.xml like:

<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>  

Upvotes: 2

Marcus
Marcus

Reputation: 6717

You have to remove the permissions you do not want from the AndroidManifest. Those permissions are tagged with <uses-permission>. Example:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Keep in mind, if you remove permissions that the app needs to function properly, your app will crash.

Also, some external libraries add their own permissions, if they are required. If you do use external libraries, check which permissions that they require. These permissions are defined at compile time and will not be visible in your manifest file.

Edit

This is where you find the manifest file in Android Studio

Android Studio Project Structure

This is where you will find it in Eclipse

Eclipse Project Structure

Upvotes: 1

Related Questions