【问题标题】:Failed to resolve: firebase-storage-19.2.0 [closed]无法解决:firebase-storage-19.2.0 [关闭]
【发布时间】: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
}

【问题讨论】:

    标签: android firebase gradle


    【解决方案1】:

    尝试将 maven { url "https://maven.google.com" } 添加到您的根级 build.gradle 文件中

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
    

    另外,从设置>Android Studio 中的实验中禁用仅同步活动变体选项

    【讨论】:

    • 我将 maven 代码添加到 build.gradle 文件中,它可以工作。谢谢!
    • 很高兴知道。乐于助人。
    猜你喜欢
    • 1970-01-01
    • 2020-05-02
    • 2019-03-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-25
    • 2018-12-02
    • 2021-07-26
    • 2018-09-07
    相关资源
    最近更新 更多