Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set android:value with a gradle properties on manifest

I have my facebook application id on my gradle properties with :

FACEBOOK_APPLICATION_ID="XXXXXXXXXXXXXXX"

and I set in my defaultConfig :

manifestPlaceholders = [facebookAppId: FACEBOOK_APPLICATION_ID]

then, I want to use this in my manifest with :

<meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="${facebookAppId}" />

but it doesn't work. The only things working are to set my faceboook id in a string :

<meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />

or to put this directly with :

<meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="\ XXXXXXXXXXXXXX" />

but I must set my facebook id in my gradle properties. What is the right way to do this ?

Thanks.

like image 587
Magnas Avatar asked Nov 19 '15 16:11

Magnas


1 Answers

I am new on Gradle, but if I understood your questions I would suggest using something like that:

buildTypes {
    debug {
        // ...
    }
    release {
        // ...
        resValue "string", "facebook_application_id", "XXXXXXXXXXXXXXXXX"
    }
}

Then, at your release build, for this example, you can use it as

android:value="@string/facebook_application_id"

Or even

R.string.facebook_application_id
like image 133
Eduardo Avatar answered Sep 28 '22 07:09

Eduardo