当我在Android Studio中运行Android应用时,出现以下错误:
Error:Build Config field cannot have a null parameter
Consult IDE log for more details (Help | Show Log)
'的build.gradle'文件代码:
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'文件代码:
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
以下是' build.gradle' app子文件夹中的代码。它有一个叫做google_nearby_api_key'的东西。不确定是否会导致此问题:
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
}
你能帮忙吗?
提前致谢
答案 0 :(得分:1)
这似乎来自这里:
resValue "string", "google_nearby_api_key",
getLocalProperties().getProperty("google_nearby_api_key")
我认为属性google_nearby_api_key
未定义。