C0D3JUNKIE
C0D3JUNKIE

Reputation: 596

Adding your API_KEY to an Android project downloaded from GitHub in the Gradle properties file

I am trying to add my API_KEY to a project downloaded from GitHub. In the ReadMe of the project, it is asking for me to update the gradle.properties file, but I do not see any such file in the project. I do see local.properties (which is where I presume I need to make the changes) and gradle-wrapper.properties file. I have tried adding the API_KEY designation to each but neither seems to work. I simply can get passed configure build step in Android Studio. Does anyone know what I am doing wrong?

The reason I presume that I update the local.properties is that it is not included in the build and therefore not exposing the API_KEY to anyone else. Is this correct?

The log link takes me to the app/build.gradle file but i presume the buildConfigField should link to the actual API_KEY in some file but I am not sure where that exists? Thanks in advance.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.2.70'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle- 
plugin:$kotlin_version"  

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

   allprojects {
        repositories {
            google()
            jcenter()
        }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Upvotes: 0

Views: 1243

Answers (1)

nupadhyaya
nupadhyaya

Reputation: 1944

gradle.properties is not the same as local.properties. Create a file named gradle.properties in you Project root folder (outermost folder) and add the api key

API_KEY = "YOUR_API_KEY"

Upvotes: 1

Related Questions