【问题标题】:I'm using firebase in my flutter app and this error appeared to me我在我的颤振应用程序中使用了 firebase,这个错误出现在我身上
【发布时间】:2020-02-03 09:13:00
【问题描述】:

我想在我的 Flutter 应用中使用 Firebase,我正在按照说明进行操作 使用 firebase 并得到该错误。

Launching lib\main.dart on Google Nexus 5X, 8 0, API 26, 1080x1920 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
ERROR: [TAG] Failed to resolve variable '${junit.version}'
ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'

FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务 ':app:processDebugGoogleServices' 执行失败。

    找不到与包名称“com.technoscans.neolearn”匹配的客户端

  • 试试:

使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

在 2m 18s 内构建失败 完成错误:Gradle 任务 assembleDebug 失败,退出代码为 1

这是 build.gradle 文件

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

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

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
}

这是 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: '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 "com.technoscans.neolearn"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    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"
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

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

【问题讨论】:

  • 你能显示你的 build.gradle 文件吗
  • 我已经用 build.gradle 文件 @ViddyutKhanvilkar 编辑了这个问题

标签: flutter mobile-development


【解决方案1】:

尝试 Flutter clean,重新获取包。并通过运行 flutter run verbose 发布更多信息。我总是在使用 4.2 版本时遇到困难,所以使用 类路径 'com.google.gms:google-services:3.2.0'

【讨论】:

    猜你喜欢
    • 2021-08-28
    • 2020-12-20
    • 2021-05-01
    • 2022-01-09
    • 2020-03-15
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多