我在 gradle build 运行时收到此错误:指定为非空的参数为空

问题描述 投票:0回答:1

当项目同步时,我在第 18 行 resVlaue("") 处收到以下错误: 评估项目“:app”时出现问题。

指定非null的参数为null:方法com.android.build.gradle.internal.dsl.BaseFlavor.resValue,参数值 应用插件:'com.android.application' 应用插件:'kotlin-android' 应用插件:'kotlin-android-extensions' 应用插件:'kotlin-kapt' 应用插件:“androidx.navigation.safeargs”

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def fbApiScheme = properties.getProperty('fbApiScheme')
def fbApiKey = properties.getProperty('fbApiKey')

android {
  lintOptions {
    baseline file("lint-baseline.xml")
  }
  compileSdkVersion  rootProject.ext.compileSdk
  defaultConfig {
    resValue("string", "fbApiKey", fbApiKey)
    resValue("string", "fbApiScheme", fbApiScheme)
    vectorDrawables.useSupportLibrary = true
    applicationId "org.aossie.agoraandroid"
    minSdkVersion rootProject.ext.minSdk
    targetSdkVersion targetSdk
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    debug {
      debuggable true
    }
  }
  buildFeatures {
    dataBinding = true
  }
  kotlinOptions {
    jvmTarget = JavaVersion.VERSION_1_8.toString()
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation "androidx.appcompat:appcompat:$appCompatVersion"
  implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
  implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  testImplementation "junit:junit:$junitVersion"
  androidTestImplementation "androidx.test:runner:$testRunnerVersion"
  androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCoreVersion"
  // Lifecycle components
  implementation "androidx.lifecycle:lifecycle-extensions:$archLifecycleVersion"
  kapt "androidx.lifecycle:lifecycle-compiler:2.3.1"
  //Design Support Library
  implementation "com.google.android.material:material:$materialDesignVersion"
  //Library for CardView
  implementation "androidx.cardview:cardview:$cardViewVersion"
  //Retrofit
  implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
  implementation "com.squareup.retrofit2:converter-scalars:$retrofitConverterScalarsVersion"
  //GSON and GSON converter
  implementation "com.squareup.retrofit2:converter-gson:$retrofitConverterGsonVersion"
  implementation "com.google.code.gson:gson:$gsonVersion"
  //Navigation Architecture Dependencies
  implementation "androidx.navigation:navigation-fragment-ktx:$navFragmentVersion"
  implementation "androidx.navigation:navigation-ui-ktx:$navUiVersion"
  //Shimmer
  implementation "com.facebook.shimmer:shimmer:$facebookShimmerVersion"
  //Facebook Login
  implementation "com.facebook.android:facebook-login:$facebookLoginVersion"
  implementation 'com.facebook.android:facebook-android-sdk:9.1.0'
  //Pie Chart
  implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
  //MockWebServer and Roboelectric
  testImplementation "org.robolectric:robolectric:$robolectricVersion"
  testImplementation "com.squareup.okhttp3:mockwebserver:$mockWebServerVersion"
  // Mockito
  testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
  testImplementation 'org.json:json:20210307'
  //kotlin deps
  implementation "androidx.core:core-ktx:1.3.2"
  implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' //TODO
  implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31'
  //dagger
  implementation "com.google.dagger:dagger:$daggerVersion"
  kapt "com.google.dagger:dagger-compiler:$daggerVersion"
  //Shared Prefs
  implementation "androidx.preference:preference-ktx:$prefsVersion"
  // room
  implementation "androidx.room:room-runtime:$roomVersion"
  kapt "androidx.room:room-compiler:$roomVersion"
  implementation "androidx.room:room-ktx:$roomVersion"
  // coroutine
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3-native-mt'
  //horizontal calendar
  implementation "devs.mulham.horizontalcalendar:horizontalcalendar:$calendarVersion"
  //day view lib
  implementation "com.linkedin.android.tachyon:tachyon:$tachyonVersion"
  //picasso
  implementation "com.squareup.picasso:picasso:$picassoVersion"
  //timber
  implementation "com.jakewharton.timber:timber:$timberVersion"
  //httpLoggingInterceptor
  implementation "com.squareup.okhttp3:logging-interceptor:$httpLoggingInterceptor"
  //chucker
  debugImplementation "com.github.chuckerteam.chucker:library:$chuckerVersion"
  releaseImplementation "com.github.chuckerteam.chucker:library-no-op:$chuckerVersion"

  //leakcanary
  debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanaryVersion"
}
repositories {
  mavenCentral()
}
android gradle build.gradle dsl internals
1个回答
0
投票

在 local.properties 添加您的 facebook api 密钥和 api 方案 像这样 - fbapikey =“值”

fbapiscgeme =“值”

然后重建项目

问题出现在 resValue("string", "fbApiKey", fbApiKey) 行 resValue(“字符串”,“fbApiScheme”,fbApiScheme)

© www.soinside.com 2019 - 2024. All rights reserved.