Search code examples
androidappceleratorandroid-permissions

Removing unnecessary Android permissions in builds


I've developed a cross platform app with Axway Appcelerator Titanium, however when building for Android, a number of unnecessary or unused permissions are added to the AndroidManifest.xml file. The following example is from said file for a Google Play build:

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

The only permission I required was android.permission.INTERNET, however the others result in a rather disturbing permissions dialog on Google Play when installing, as this application definitely doesn't require reading/writing [to] external storage.

I've set <analytics>false</analytics> in tiapp.xml, and manually created another AndroidManifest.xml file excluding these permissions in the app's platform directory, but all builds still include them. Building a fresh example Alloy project also results in the inclusion of the above four dependencies.

Is there any way to resolve the issue with these unneeded dependencies?

I'm using Android API 26, Ti SDK 6.2.2GA with Axway Appcelerator Studio on macOS 10.13, and have also tried Ti SDK 6.1.1GA and Android API 23.


Solution

  • Since 6.1.0 you can set <override-permissions>true</override-permissions> in tiapp.xml to remove all build-in permissions.

    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:versionCode="1" android:versionName="1.0">
            <application></application>
            <uses-permission android:name="android.permission.INTERNET"/>
        </manifest>
        <abi>armeabi-v7a</abi>
    </android>
    

    See the PR for more infos: https://github.com/appcelerator/titanium_mobile/pull/8881