I checked on my machine that this works for me
local.properties
GOOGLE_NEARBY_API_KEY="XXXXXXXXXX"
build.gradle
Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) resValue "string", "google_nearby_api_key", properties.getProperty('GOOGLE_NEARBY_API_KEY')
You will find the generated file with your line in:
app/build/generated/res/resValues/{build-type}/values/generated.xml
Now you can use the string in your application as @string/google_nearby_api_key .
Also, when I removed the key from local.properties , I get the same error:
Error:(17, 1) A problem occurred evaluating project ':app'. > Build Config field cannot have a null parameter
So you probably don't have a key in local.properties .
And you also seem to have manually added a line to your strings.xml resource strings.xml , you shouldn't do this if you want to hide your API key. Add it using the gradle assembly (the approach described above).
source share