0

Is it possible to add a variable to manifests.xml file ?

For example, I'm setting FCM for my app and there's a piece of code:

<meta-data
    android:name="com.google.firebase.messaging.default_notification_channel_id"
    android:value="@string/default_notification_channel_id" />

My app need the @string/default_notification_channel_id changeable, is there any particalar way to do that ?

Many thanks!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

1

You can use manifest placeholder for that, Using It you will be able to have these based on app flavours

In your build.gradle file.

debug {
  minifyEnabled false
  debuggable true
  applicationIdSuffix ".debug"
  manifestPlaceholders = ["default_notification_channel_id": "abcdefgh"]
}
release {
  minifyEnabled true
  debuggable false

  manifestPlaceholders = ["default_notification_channel_id": "xyzuvw"]
}

and In your AndroidManifest file

<meta-data
  android:name="com.google.firebase.messaging.default_notification_channel_id"
  android:value="${default_notification_channel_id}"/>
akashzincle
  • 1,108
  • 6
  • 15