【发布时间】: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 -
那个错误是因为你的
compileSdkVersion 26改成compileSdkVersion 27
标签: android firebase android-studio gradle