MobileAppDeveloper
MobileAppDeveloper

Reputation: 1049

Configure build.gradle for building apps with different application id

I need to generate different apks from the same code. The only difference would be the applicationId defined in build.gradle. I have defined some permissions in AndroidManifest. These permissions start with the application id. e.g.

APK1 build.gradle applicationId 'com.example.app1'

Android Manifest

uses-permission android:name="com.example.app1.permission.PERMISSION_NAME"

APK2 build.gradle applicationId 'com.example.app2'

Android Manifest

uses-permission android:name="com.example.app2.permission.PERMISSION_NAME"

I need to know an efficient way to achieve this. If possible, I would like to avoid creating two different AndroidManifest files depending on the flavour. Please suggest.

Upvotes: 0

Views: 169

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 365028

You can use the ${applicationId} placeholder.
Something like:

<uses-permission android:name="${applicationId}.permission.PERMISSION_NAME" />

Upvotes: 1

Related Questions