简体   繁体   中英

How to configure dynamic app_id programmatically for Google Play game services?

In my project I need to configure app_id at runtime, but for now I have found only one way, with Manifest.

<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id"/>

Can I do it progammatically? Maybe in nearest releases?

If you are using Android Studio for you application programming than you can achieve it by declaring you app_id string resource in app Gradle file.

Declare it in:

android {
    defaultConfig {
            applicationId "<YOUR PACKAGE>"
            .....
            resValue "string" "app_id" getApplicationId()
    }
}

and now you'll easily find the string resource R.string.app_id, which is automatically generated for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM