Android Studio + Gradle: define resValue without translation, how can I do this?

When defining resources with resValue in build.gradle, it is not possible to mark them as translatable = "false". In XML, this is possible.

Exemple:

In gradle.properties:

FACEBOOK_APP_ID="XXXXXXXXXXXXX" 

In gradle:

 resValue "string", "FACEBOOK_APP_ID", FACEBOOK_APP_ID 

When I want to generate a signed APK, there is a translation error in this line because it has not been translated into another language ... but this is normal, I do not want to translate it.

+5
source share
3 answers

Gradle does not support this one yet . You cannot add anything notranslate like to your gradle file.

You can add FACEBOOK_APP_ID to exclude translation verification of lint. Missing translation

https://code.google.com/p/android/issues/detail?id=152198

+4
source

I have the same error loading apk in google I resolved it by adding translatable = false it works with me

 <String Name = "Facebook_app_id" translatable = "false" >01234567890</String> 
+4
source

You can add it to /string.xml with the flag translatable = "false"

 <string name="facebook_app_id" translatable="false">YOUR_FACEBOOK_APP_ID</String> 

Or you can add FACEBOOK_APP_ID to your gradle file using resValue or buildConfigField . Something like that:

 buildTypes { debug { buildConfigField "string", "facebook_app_id1", "YOUR_FACEBOOK_APP_ID" resValue "string", "facebook_app_id", "YOUR_FACEBOOK_APP_ID" } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "string", "facebook_app_id1", "YOUR_FACEBOOK_APP_ID" resValue "string", "facebook_app_id", "YOUR_FACEBOOK_APP_ID" } } 

Customs:

 // buildConfigField BuildConfig.FACEBOOK_APP_ID1 // resValue getString(R.string.FACEBOOK_APP_ID) 
+3
source

Source: https://habr.com/ru/post/1231926/


All Articles