userash
userash

Reputation: 1473

Build config error in Android Studio

When I run the Android App in Android Studio, I get the following error:

Error:Build Config field cannot have a null parameter

Consult IDE log for more details (Help | Show Log)

'build.gradle' file code:

buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.1.1'
  }
}

allprojects {
  repositories {
    google()
  }
}

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

'gradle-wrapper.properties' file code:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Here is the below 'build.gradle' code inside the app subfolder. It has something called 'google_nearby_api_key'. Not sure if that's causing the issue:

buildscript {
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }

  dependencies {
    classpath 'io.fabric.tools:gradle:1.25.1'
  }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
  jcenter()
  google()
  maven { url 'https://maven.fabric.io/public' }
  maven { url 'https://jitpack.io' }
}

android {
  compileSdkVersion 27
  buildToolsVersion '27.0.3'

  defaultConfig {
    applicationId "com.sg.blahblah"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 24
    versionName "1.0.4"
    testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'

    def filesAuthorityValue = applicationId + ".files"
    manifestPlaceholders = [filesAuthority: filesAuthorityValue]
    buildConfigField "String", "FILES_AUTORITY", "\"${filesAuthorityValue}\""
    resValue "string", "google_nearby_api_key",
        getLocalProperties().getProperty("google_nearby_api_key")
  }

  buildTypes {
    release {
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

  packagingOptions {
    exclude 'LICENSE'
    exclude 'LICENSE.txt'
    exclude 'NOTICE'
    exclude 'asm-license.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/services/javax.annotation.processing.Processor'
  }
}

dependencies {
  implementation 'com.android.support:appcompat-v7:27.0.2'
  implementation 'com.android.support:cardview-v7:27.0.2'
  implementation 'com.android.support:design:27.0.2'
  implementation 'com.google.android.gms:play-services-nearby:11.8.0'
  implementation 'com.google.android.gms:play-services-appinvite:11.8.0'
  implementation 'com.google.android.gms:play-services-analytics:11.8.0'
  // Dagger
  implementation 'com.google.dagger:dagger:2.14'
  annotationProcessor 'com.google.dagger:dagger-compiler:2.14'
  // Logging
  implementation 'com.jakewharton.timber:timber:4.5.1'
  // View injection
  implementation 'com.jakewharton:butterknife:8.8.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
  // Database
  implementation 'com.j256.ormlite:ormlite-android:4.48'
  // Fonts
  implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
  // Image loading
  implementation 'com.squareup.picasso:picasso:2.5.2'
  // Crop avatar
  implementation 'com.lyft:scissors:1.0.1'
  // JSON serialization
  implementation 'com.google.code.gson:gson:2.8.2'
  // Crash & usage monitoring
  implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
    transitive = true;
  }
  // Generate fake data
  implementation 'com.github.blocoio:faker:1.2.5'
  // Testing
  testImplementation 'junit:junit:4.12'
  testImplementation 'org.mockito:mockito-core:2.10.0'
  androidTestImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support:support-annotations:27.0.2'
  androidTestImplementation 'com.android.support.test:runner:1.0.1'
  androidTestImplementation 'com.android.support.test:rules:1.0.1'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  androidTestImplementation('com.android.support.test.espresso:espresso-contrib:3.0.1') {
    exclude module: 'recyclerview-v7'
    exclude module: 'support-v4'
  }
}

apply plugin: 'com.google.gms.google-services'

def getLocalProperties() {
  Properties properties = new Properties()
  properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())
  return properties
}

Can you please help?

Thanks in advance

Upvotes: 0

Views: 2209

Answers (1)

Henry
Henry

Reputation: 43798

This seems to come from here:

resValue "string", "google_nearby_api_key",
    getLocalProperties().getProperty("google_nearby_api_key")

I guess the property google_nearby_api_key is not defined.

Upvotes: 1

Related Questions