越来越cloud_firestore:0.9.0依赖关系打破了扑扑的应用程序

时间:2019-01-29 12:16:30

标签: android firebase dart flutter package

我已将cloud_firestore: ^0.9.0软件包添加到新的flutter项目中,因此我创建了一个新的flutter项目,仅用于测试Firebase软件包。

在“打包获取”之后,并启动项目后出现此错误。

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve com.google.firebase:firebase-firestore:17.1.0.
  Required by:
      project :app > project :cloud_firestore
   > Could not resolve com.google.firebase:firebase-firestore:17.1.0.
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
         > Could not GET 'https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
            > Connect to dl.google.com:443 [dl.google.com/172.217.19.110] failed: Connection timed out: connect
   > Could not resolve com.google.firebase:firebase-firestore:17.1.0.
      > Could not get resource 'https://jcenter.bintray.com/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
         > Could not GET 'https://jcenter.bintray.com/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
            > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/52.28.74.46, jcenter.bintray.com/52.28.100.213] failed: Connection timed out: connect
   > Could not resolve com.google.firebase:firebase-firestore:17.1.0.
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
         > Could not GET 'https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
            > Connect to dl.google.com:443 [dl.google.com/172.217.19.110] failed: Connection timed out: connect
   > Could not resolve com.google.firebase:firebase-firestore:17.1.0.
      > Could not get resource 'https://jcenter.bintray.com/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
         > Could not GET 'https://jcenter.bintray.com/com/google/firebase/firebase-firestore/17.1.0/firebase-firestore-17.1.0.pom'.
            > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/52.28.100.213, jcenter.bintray.com/52.28.74.46] failed: Connection timed out: connect

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 7s
Finished with error: Gradle task assembleDebug failed with exit code 1

重新创建步骤:

  1. 复制pubspec.yaml cloud_firestore的Firebase软件包版本:^ 0.9.0并将其添加到pubspect.yamel文件中。并获得包裹。
  2. 在firebase网站上创建帐户后,下载了google-services.json。
  3. FLUTTERAPP / android / buld.grundle ive添加了这一行代码

    classpath'com.google.gms:google-services:4.2.0'

  4. FLUTTERAPP / android / app / build.grundle最后我添加了这样的代码

    应用插件:“ com.google.gms.google-services”

启动了应用程序。

我在Windows 10上将Android Studio与Android模拟器配合使用

MY_APP / android / buld.randle

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
}

MY_APP / android / app / build.grundle

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 27

    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.example.newapp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.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"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

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

2 个答案:

答案 0 :(得分:1)

问题[RE:Flutter如何解决。.dex文件中方法引用的数量不能超过64K。]可以通过将app / build.gradle minSdkVersion值从16更改为21来解决。与我以前遇到的问题相同(或相关),但有不同的错误消息。

答案 1 :(得分:0)

您还应该添加要使用的Firebase SDK的依赖项。

添加implementation 'com.google.firebase:firebase-core:16.0.1'  到您的MY_APP / android / app / build.grandle文件中的依存关系部分,如下所示。

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
}

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