Issue
I have defined a property in my ~/.gradle/gradle.properties
and I want to access it in a string resources file.
Definition in ~/.gradle/gradle.properties
ServerIP="XXX.XXX.XX.XX"
Declaration in app/build.gradle
android {
buildTypes.each {
it.resValue "string", "ServerIP", "SERVER_IP"
}
}
Usage in string/web_services.xml
<string name="serverIP">@string/SERVER_IP</string>
Error during build
Error:(4, 5) No resource found that matches the given name (at 'serverIP' with value '@string/SERVER_IP').
Is there any way to achieve this or it can't be done?
Solution
The problem is with this line:
it.resValue "string", "ServerIP", "SERVER_IP"
The first argument is type, the second is name and the third is value. In your case name should be "SERVER_IP"
and value should be ServerIP
without quotes. So final piece in build.gradle
:
android {
buildTypes.each {
it.resValue "string", "SERVER_IP", ServerIP
}
}
Answered By - Alexander Mironov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.