【问题标题】:Do I need to update or change anything in my gradle files?我需要更新或更改我的 gradle 文件中的任何内容吗?
【发布时间】:2021-12-01 23:22:21
【问题描述】:

“评估项目 ':app' 时出现问题。”

我尝试查看此错误的旧解决方案,但其中一些建议是更改版本。那是我应该做的吗?如果是这样,我应该更改为哪个版本?这与我的其他错误“未找到 ID 为 'com.google.gms.google-services:4.3.10' 的插件”有关吗?

android/build.gradle:

buildscript {
    ext.kotlin_version = '1.5.31'
    repositories {
        google()
        mavenCentral()
    }

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

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

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

app/build.gradle:

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

android {
    compileSdkVersion 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.app.app"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        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 'androidx.multidex:multidex:2.0.1'
}

gradel-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-x64, locale en-CA)

[✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 31.0.0)

[✓] Xcode - 为 iOS 和 macOS 开发

[✓] Chrome - 为网络开发

[✓] Android Studio(版本 2020.3)

【问题讨论】:

  • 您面临的错误是什么? “评估项目 ':app' 时出现问题。”之后呢?

标签: android flutter gradle


【解决方案1】:

在“app/build.gradle”文件的顶部,你有:

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

这不应包括版本。

您在项目 build.gradle 文件中定义版本(您发布的第一个)

应该是:

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

【讨论】:

  • 谢谢!这修复了错误......但现在我有错误“任务':app:compileDebugKotlin'的执行失败。”这是相关的还是我应该发布一个不同的问题?
猜你喜欢
  • 2011-04-30
  • 2020-05-27
  • 2018-09-20
  • 2021-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多