5

How to include variable from build.gradle inside AndroidManifest data tag.

I tried

<data scheme="${applicationId}.something">

But I received the error NullPointerException: No record for key [data]

  • possible duplicate of https://stackoverflow.com/questions/28954071/how-can-i-access-a-buildconfig-value-in-my-androidmanifest-xml-file – Karthik Kumar Dec 11 '17 at 14:19

1 Answers1

1

You can try

...
defaultConfig {
...

   buildConfigField("String", "PROVIDER_KEY", "\"$applicationId\"")
   manifestPlaceholders = [providerKey: "$applicationId"]

}

And using

<provider
        android:name=".provider.NavigationMenuContent"
        android:authorities="${providerKey}"
        android:exported="false" />

or

static final String AUTHORITY = BuildConfig.PROVIDER_KEY;

See docs https://developer.android.com/studio/build/gradle-tips https://developer.android.com/studio/build/manifest-build-variables