GoogleCloudPlatform / cloud-vision

Sample code for Google Cloud Vision
https://cloud.google.com/vision
Apache License 2.0
1.1k stars 890 forks source link

Could not find buildConfigField() #148

Closed TLKG closed 2 years ago

TLKG commented 6 years ago

Downloaded the source code two weeks ago, followed ReadMe.cmd to open just android\CloudVision using Studio 3.1.4, kept getting Gradle 'CloudVision' project refresh failed' after installed all updates for this Studio. Environment = Win10, 64-bit

Error:Could not find method buildConfigField() for arguments [String, API_KEY, BuildType_Decorated{name=ApiKey, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}] on BuildType_Decorated{name=debug, debuggable=true, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=SigningConfig_Decorated{name=debug, storeFile=C:\Users\MyName\.android\debug.keystore, storePassword=android, keyAlias=AndroidDebugKey, keyPassword=android, storeType=C:\Users\MyName\.android\debug.keystore, v1SigningEnabled=true, v2SigningEnabled=true}, embedMicroApp=false, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.

Haggr commented 5 years ago

When you click on "Open File" below the error, it will open the relevant file with the cursor on the relevant line. This line should be:

it.buildConfigField 'String', 'API_KEY', api_key

You are supposed to replace api_key with your API key like so:

it.buildConfigField "String", "API_KEY", '"a1B2c3kdsjfl32l34wslf3tHisKeyiSMadEuP234"'

Then you can sync successfully.