saulspatz
saulspatz

Reputation: 5261

Android Product Flavors Manifests

I'm working on my first android app, and I'm just getting started with product flavors. I have a free version in beta, and I'm starting to make a a paid version. I'm a bit confused about the manifests.

The paid version will have one activity that the free version does not, and the two will have different permissions. I'm thinking that I will remove the permissions from the main manifest, that the free manifest will have nothing in it but its permissions, and the paid manifest will have nothing in it but its permissions and the extra activity.

For example, the free manifest might be

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">

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

</manifest>

Is this correct?

Upvotes: 3

Views: 2563

Answers (1)

Pablo Baxter
Pablo Baxter

Reputation: 2234

That's correct, however, I would recommend you put all common Manifest information in the main, as CommonsWare mentioned.

Also, as a tip, if you do need to replace a value in the main Manifest for any reason (debugging for example), I would use the tools:replace tag like so:

Free flavor:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.example">

    <application
        android:name=".FreeApp"
        android:allowBackup="false"
        tools:replace="allowBackup,name"/>

</manifest>

This would replace the tags name and allowBackup from main with what you have in this manifest.

I recommend you check out the following link for more information about flavoring and variants, in case you haven't already:

https://developer.android.com/studio/build/build-variants.html

Upvotes: 3

Related Questions