android - 无法获取“https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.0.1/google-services-4.0.1.pom”
问题描述
在 Firebase 身份验证(助手)中使用向您的应用添加 Firebase 身份验证时出错。
错误在同步选项卡中显示为:
无法获取“ https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.0.1/google-services-4.0.1.pom ”。从服务器收到状态码 405:不允许方法启用 Gradle '离线模式'并同步项目
我的 Android Studio 详细信息是:
- 安卓工作室版本 3.2.1
- 摇篮版本:4.6
build.gradle (项目)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(应用程序)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nsc.suyog.myotp1"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
}
解决方案
尝试更改以下代码(项目):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven { url "http://jcenter.bintray.com"}
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "http://jcenter.bintray.com"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
和(应用程序):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nsc.suyog.myotp1"
minSdkVersion 21
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'
}
}
}
android { lintOptions { abortOnError false }
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-auth:16.1.0'
}
同样在gradle-wrapper.properties添加此行或更改如果已经存在其他值:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
推荐阅读
- ios - 我的 .txt 文件在加载文本时会滞后 - 保存到 Firebase 并从那里加载可以加快速度吗?
- mongodb - MongoDb 分片和唯一约束
- powerbi - PowerBI 门户中 Cosmos DB 的数据刷新
- json - jq:从多个对象中查找唯一键
- php - 上个月,下个月和月份,年份在日历 PHP 中不起作用
- javascript - 获取奇怪的未捕获类型错误:this._saveFile 不是 es6 的函数
- c++ - C ++字符串到整数错误值可以反转吗?
- java - 了解 Google Cloud Platform 上的实例小时数
- python - 如何创建临时令牌 django
- html - 如何将一个href页面制作成另一个文件夹中的入门工具包