I am currently working on an Android Kotlin project. In this project, I need to retrieve certain keys from the local.properties file and subsequently utilize them in the AndroidManifest.xml file. However, I have encountered an issue where I receive a warning stating that
'property 'googleMapsApiKey' does not exist'.
I have attempted to resolve this problem by cleaning and rebuilding the project, but unfortunately, I have not been successful. Below is the code snippet in question:
Gradle (App Level) code :
defaultConfig {
applicationId "com.testapp.myfirstapp"
minSdk 23
targetSdk 34
versionCode 8
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
if (properties.containsKey('MAPS_API_KEY')) {
manifestPlaceholders = [googleMapsApiKey: "${properties.getProperty('MAPS_API_KEY')}"]
} else {
println "Warning: MAPS_API_KEY not found in local.properties"
}
}
local.properties code :
MAPS_API_KEY=APIkeysssd1201232ApiTestKeyStack
manifest code :
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${googleMapsApiKey}" />
Having the same problem. The IDE suggestion creates a "Dynamic Member" which got rid of the warning as mentioned. But since I could not find any documentation how these "Dynamic Members" work, I went with a different way of defining the placeholder, which also does not raise any Lint warning:
manifestPlaceholders["key"] = "value"