【问题标题】:Firebase not working Android Studio 3.0.1 [com.android.support:support-core-utils:27.1.0]Firebase 不工作 Android Studio 3.0.1 [com.android.support:support-core-utils:27.1.0]
【发布时间】:2018-03-08 18:21:22
【问题描述】:

我正在尝试将 Firebase 与我的项目同步,我使用 Android Studio 中的工具 --> Firebase,然后执行步骤(这是新项目)Image。 Android Studio 版本 3.0.1

App文件夹中的build.gradle是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.eranp.fiberbase"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}


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

Project文件夹中的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        compile "com.android.support:support-core-utils:27.1.0"


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

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

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

但是当我同步项目时出现这个错误:

错误:(13, 0) 找不到参数的方法 compile() [com.android.support:support-core-utils:27.1.0] 对象类型 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。

请从 Android SDK 安装 Android Support Repository 经理。

但这是安装的:Image

我尝试了一周来使用 Firebase,但一切都可以同步。 我怎样才能解决这个问题? 谢谢你的帮助!

【问题讨论】:

  • 转到文件 -> 设置 -> SDK -> SDK 工具 -> 检查安装构建工具 并应用
  • 也不起作用:( ibb.co/cjvNf7
  • imlementation 'com.android.support:support-compat:27.1.0' 将此作为依赖项添加到 gradle 并将 tye compileSdkVersion 更改为 27
  • 错误:ibb.co/ii6L07
  • 那个错误是因为你的compileSdkVersion 26改成compileSdkVersion 27

标签: android firebase android-studio gradle


【解决方案1】:

添加后:

compile "com.android.support:support-core-utils:27.1.0"

在app/build.gradle中的依赖项下

那么你需要改变:

 compileSdkVersion 26

到这里:

 compileSdkVersion 27

还将 firebase 版本更新为:

implementation 'com.google.firebase:firebase-database:11.8.0'

最新版本

【讨论】:

    【解决方案2】:

    您正在尝试将compile 依赖项添加到您的项目构建脚本中,这是无效的。您只应该将 classpath 依赖项添加到您的构建脚本中,它们可以有效地充当您的 Gradle 构建的插件。

    compile 依赖项将使用您应用的 build.gradle,它通常位于 app 文件夹中。这些是您用于构建应用的 SDK 组件。

    如果您想在您的应用中使用compile "com.android.support:support-core-utils:27.1.0",请将其从 buildscript 依赖项移至应用程序依赖项。

    【讨论】:

    • 这看起来是一个完全不同的问题。
    • 我知道,但我该如何解决这个问题?
    • 如果您遇到的问题与您最初发布的问题不同,请提出不同的问题。
    猜你喜欢
    • 2023-04-06
    • 2020-01-09
    • 1970-01-01
    • 2019-04-07
    • 2018-09-17
    • 2014-08-27
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    相关资源
    最近更新 更多