Сбой сборки Gradle при использовании плагина google_sign_in для флаттера

Приложение отлично компилируется, если не используется плагин (google_sign_in). Но как только я добавлю его как зависимость в pubspec.yaml, приложение не будет собираться.

Это ошибка gradle, которую я получаю:

* What went wrong:
A problem occurred configuring project ':google_sign_in'.
    > Could not resolve all artifacts for configuration ':google_sign_in:classpath'.
         > Could not find kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.11).
           Searched in the following locations:
               https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.11/kotlin-reflect-1.3.11.jar
    
    > Could not get unknown property 'android' for project ':google_sign_in' of type org.gradle.api.Project.

Я попытался щелкнуть ссылку на kotlin-reflect-1.3.11.jar, и он загружает файл, поэтому ссылка явно работает.

Я пробовал возиться с разными версиями почти всего, но я не нашел ничего, что работает...

Вот мой файл pubspec.yaml:

name: wishtogether
description: A new Flutter application.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase_core: 0.5.3
  firebase_auth: ^0.18.4+1
  google_sign_in: ^4.5.6
  provider: ^4.3.2+3
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true

build.gradle на уровне проекта:

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

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

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
}

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.google.gms.google-services' //Firebase
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 29

    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.jonathan.wishtogether"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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 platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.firebase:firebase-analytics'
}

Любые предложения или идеи относительно того, что может быть не так? Спасибо!

2
0
509
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

измените версию Gradle в файле google_sign_in build.gradle, чтобы она соответствовала версии в папке Android в приложении флаттера.

после запуска флаттер чистый.

затем запустите свой проект.

Где найти общие настройки build.gradle? И почему это может быть проблемой, если я даже не использую общие настройки?

TheEggHealer 23.12.2020 10:47

Я решил это, перейдя в build.gradle google_sign_in и изменив версию gradle, чтобы она соответствовала моей. Для тех, у кого могут возникнуть проблемы с его поиском, это путь: flutter_sdk/.pub-cache/hosted/pub.dartlang.org/google_sign_i‌​n-4.5.6/android. Если @Tharaka Dayanjana изменит его с общих настроек на google_sign_in, я могу отметить ответ как решение.

TheEggHealer 23.12.2020 10:59

Другие вопросы по теме