如何解决“由于上述问题,无法构建插件cloud_firestore。”

时间:2020-04-22 04:44:23

标签: firebase android-studio flutter

我仍在学习Firebase和Flutter。当我第一次尝试连接Firebase时,出现错误。我按照Firebase网站中的说明逐步安装了它。但是在android studio中,红色下划线显示了错误的内容。我该如何解决?

在此文件中,他显示错误。这是安装Firebase时编辑的文件 Project / app / build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "kasun.com.flutterbookmanger"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex.1.0.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

查看此屏幕截图enter image description here

这是另一个已编辑的文件。 Proect / build.gradle文件

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

错误代码enter image description here 如何解决这个问题?请帮忙。

4 个答案:

答案 0 :(得分:0)

尝试更新 gradle 版本,应该可以正常工作

在 Proect/build.gradle 文件中

$a1=array(1,1,2);
$a2=array(1,2);
$a3=array(1,1);
$a4=array(1,1,3);
$a5=array(1,1,1,1);

$same= array();
for($i=0; $i<3; $i++){
    while($a1[$i]==$a2[$i] && $a1[$i]==$a3[$i] && $a1[$i]==$a4[$i] && $a1[$i]==$a5[$i]){
        array_push($same, $a1[$i]);
    }
}
print_r($same);

那么你必须在 YOUR_APPLICATION_FOLDER/gradle/wrapper/gradle-wrapper.properties 中更新它

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.1'
    ...
    ...

这帮我解决了同样的错误

答案 1 :(得分:0)

试试这个:

def flutterRoot = localProperties.getProperty('flutter.sdk')
 if (flutterRoot == null) {
 throw new FileNotFoundException("Flutter SDK not found. Define location with 
 flutter.sdk in the local.properties file.")
 }

我遇到了这个问题,它与 firebase 无关。

答案 2 :(得分:0)

我通过从模拟器(内存)关闭应用程序解决了这个问题。并从头开始,希望对您也有帮助。

答案 3 :(得分:0)

神奇的命令行“flutter clean”为我完成了这项工作