【发布时间】:2020-10-09 10:51:18
【问题描述】:
我已经花了几个小时,并且还尝试了其他答案中提到的方法,例如降级依赖项并安装 Google 存储库(我的 Android Studio 没有在 SDK 管理器中显示 Google 存储库),但它们都不是有帮助。错误仍然存在。
这是我的 .gradle 文件,我还提到了我必须使用 Google() 或 maven{ url "https://maven.google.com" } 以外的其他 maven 源的原因:
build.gradle (:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "comp5216.sydney.edu.au.takenshowphotos"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-core:17.5.1'
implementation 'com.google.firebase:firebase-auth:19.4.0'
// The error occurs only if I added this line
implementation 'com.google.firebase:firebase-storage:19.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(项目)
// Top-level build file where you can add configuration options common to all sub-
projects/modules.
buildscript {
repositories {
// If I delete the maven lines, I will only get the "Cause: invalid type code: B4" error
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/google'
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
}
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.2"
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// If I delete the maven lines, I will only get the "Cause: invalid type code: B4" error
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/google'
}
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】: