Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set build.gradle value to a value written in xml file

Is there away to set a variable in the build.gradle file to a value set in the strings.xml file?

For example say I have this in my strings.xml file:

<string name="version">"1.0.0"</string>

And in my build.gradle file I had something along these lines:

 versionName: @strings/version
like image 368
Ryan Avatar asked Aug 31 '25 05:08

Ryan


1 Answers

Afaik, as of now it's unavailable to read from string resource files, Android Gradle Plugin does not have such an API.

Instead, you can do the opposite using resValue() API: you can write a value to resources within build.gradle:

resValue "string", "variable_name", "some value here"
like image 147
azizbekian Avatar answered Sep 02 '25 19:09

azizbekian