【问题标题】:mavenCentral() is not working instead jcenter()mavenCentral() 不工作,而不是 jcenter()
【发布时间】:2021-10-23 17:50:20
【问题描述】:

mavenCentral() 不工作,而不是 jcenter()。当我使用 mavenCentral() 时,我收到以下错误消息,

Could not HEAD 'https://google.bintray.com/flexbox-layout/com/google/android/flexbox/2.0.1/flexbox-2.0.1.pom'. Received status code 403 from server: Forbidden
Disable Gradle 'offline mode' and sync project

使用上面的 jcenter() 不会出现错误。

即使在不推荐使用 jcenter() 之后,我也可以在我的项目中使用 jcenter()。在我们的项目中使用 jcenter() 的最后日期是什么时候。

项目 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.3'
        classpath 'com.google.gms:google-services:4.3.8'
        //classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.24.4"
    }
}

allprojects {
    /*apply plugin: 'com.jfrog.artifactory'
    apply plugin: 'maven-publish'*/

    repositories {
        google()
        mavenCentral()
    }
}

模块 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "io.kommunicate.app"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

          //Sensitive data
    }

    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        //jcenter()
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //api project(':kommunicateui')
    implementation 'io.kommunicate.sdk:kommunicateui:2.1.8'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 可以发一下build.gradle吗?
  • @Skizo-ozᴉʞS 我添加了 app build.gradle。请看。
  • 你能保持 jcenter() 吗?仍然有一些 api 需要它。两者都保留。
  • 请同时添加您的项目的 build.gradle,而不是应用程序
  • 如果您的国家/地区受到 google 制裁(403:禁止),请使用 vpn

标签: android deprecated jcenter


【解决方案1】:

Maven Central 上没有 flexbox。在Google's Maven repo 上有一个flexbox,但只有3.0.0。你的一些传递依赖正在寻找 2.0.1。而且,根据该依赖关系列表,它必须是 io.kommunicate.sdk:kommunicateui:2.1.8,它正在寻找旧的 flexbox

很遗憾,io.kommunicate.sdk:kommunicateui 的开发人员显然还没有更新他们的库。

您可以尝试手动添加自己对 com.google.android.flexbox:flexbox:3.0.0 的依赖项,也可以在 io.kommunicate.sdk:kommunicateui:2.1.8 依赖项上设置 exclude 规则来告诉 Gradle 忽略其对 flexbox 的传递依赖项。理想情况下,io.kommunicate.sdk:kommunicateui 的开发人员会更新他们的库以依赖于com.google.android.flexbox:flexbox:3.0.0

要排除失败的依赖项,请更改:

implementation 'io.kommunicate.sdk:kommunicateui:2.1.8'

到:

implementation('io.kommunicate.sdk:kommunicateui:2.1.8') {
  exclude group: "com.google.android", module: "flexbox"
}

【讨论】:

  • 我添加了实现 'com.google.android.flexbox:flexbox:3.0.0' 但得到了同样的错误。
  • @AmitYadav:那么您可能还需要排除失败的依赖项——我更新了我的答案以显示其语法。
  • 我排除了 implementation('io.kommunicate.sdk:kommunicateui:2.1.8') { exclude group: "com.google.android", module: "flexbox" } 及其工作
【解决方案2】:

问题出在FlexBox Layout library

https://google.bintray.com/flexbox-layout/com/google/android/flexbox/2.0.1/flexbox-2.0.1.pom

你得到 403 禁止出于任何原因。有一个使用flexbox 3.0.0mavenCentral() 工件,以防您可以使用它。

https://maven.google.com/web/index.html?q=flexbox#com.google.android.flexbox:flexbox:3.0.0

您应该添加此依赖项(或在您的 io.kommunicate.sdk:kommunicateui:2.1.8 或使用 flexbox 的那个中添加排除规则)

dependencies {
    ....
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    ....
}

更多信息请阅读本帖

https://github.com/google/flexbox-layout/issues/566#issuecomment-844630491

【讨论】:

  • 我添加了实现 'com.google.android.flexbox:flexbox:3.0.0' 但得到了同样的错误。
  • 您是否将排除项放在使用 flexbox 的库中?您是否也尝试过关闭项目并清除缓存并重新启动?
  • 我没有排除。你能告诉我怎么做吗?我清除了缓存,但它不起作用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-05-13
  • 1970-01-01
  • 2018-05-25
  • 2014-04-08
  • 2020-02-15
  • 1970-01-01
相关资源
最近更新 更多