本文介绍了Android Studio:Gradle 构建错误未定义存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
安卓工作室 3.3.1
Andriod Studio 3.3.1
gradle 4.4
我通过 Android > 工具 > Firebase 选项添加了 Firebase 存储.但是,当我同步 gradle 时,构建失败.这是我得到的错误:
I added firebase storage through the Android > Tools > Firebase option. However when I sync the gradle the build fails. This is the error that I'm getting:
Cannot resolve external dependency com.google.gms:google-services:3.2.1
because no repositories are defined. Required by:project :app
有谁知道如何纠正这个错误?
build.gradle(模块:APP)
build.gradle (Module: APP)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.test"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
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'
implementation 'com.android.support:design:27.1.1'
//implementation 'com.google.android.gms:play-services:11.0.4'
}
buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
}
}
apply plugin: 'com.google.gms.google-services'
推荐答案
错误表明 repositories
丢失,以便确定从哪里下载 google-services
.
The error indicates that repositories
is missing in order to determine from where google-services
will be downloaded.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
}
}
jcenter
是对 bintray jcenter 的引用.Gradle 可以找到 google-services:3.2.1 那里.
jcenter
is a reference to bintray jcenter. Gradle can find the google-services:3.2.1 there.
这篇关于Android Studio:Gradle 构建错误未定义存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!