五一假期给我爸写一个小app,涉及一个弹窗库,是github的,发布在jetpack,
我是新版的gradle,8.4, gradle.kts

新版的gradle引入用下面的方式,和老板的不一样。

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
//        maven { setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots") }

        maven{setUrl("https://www.jitpack.io")}
    }
}

我尝试过多个版本,多个jetpack的库都无法下载下来,我查了很多博客,写的跟屎一样,抄过来超过去,又是改www,又是没有引入jetpack, 弱智一样。

解决

在gradle目录下,找到这个文件

添加配置
maven { url = uri(AliYunMaven.jitpack) }
然后重新sync就可以了!!!

完整配置如下

@file:Suppress("UnstableApiUsage")

object AliYunMaven {
    const val CENTRAL = "https://maven.aliyun.com/repository/central/"
    const val CENTRAL_JCENTER = "https://maven.aliyun.com/repository/public/"
    const val GOOGLE = "https://maven.aliyun.com/repository/google/"
    const val GRADLE_PLUGIN = "https://maven.aliyun.com/repository/gradle-plugin/"
    const val APACHE_SNAPSHOTS = "https://maven.aliyun.com/repository/apache-snapshots/"
    const val jitpack = "https://www.jitpack.io"
}

settingsEvaluated {
    pluginManagement {
        repositories {
            clear()
            maven { url = uri(AliYunMaven.CENTRAL) }
            maven { url = uri(AliYunMaven.CENTRAL_JCENTER) }
            maven { url = uri(AliYunMaven.GOOGLE) }
            maven { url = uri(AliYunMaven.GRADLE_PLUGIN) }
            maven { url = uri(AliYunMaven.APACHE_SNAPSHOTS) }
            maven { url = uri(AliYunMaven.jitpack) }
            google()
            mavenCentral()
            gradlePluginPortal()
        }
    }
    dependencyResolutionManagement {
        repositories {
            clear()
            maven { url = uri(AliYunMaven.CENTRAL) }
            maven { url = uri(AliYunMaven.CENTRAL_JCENTER) }
            maven { url = uri(AliYunMaven.GOOGLE) }
            maven { url = uri(AliYunMaven.APACHE_SNAPSHOTS) }
            maven { url = uri(AliYunMaven.jitpack) }
            google()
            mavenCentral()
        }
    }
}

分类: java

站点统计

  • 文章总数:308 篇
  • 分类总数:19 个
  • 标签总数:190 个
  • 运行天数:950 天
  • 访问总数:32867 人次

浙公网安备33011302000604

辽ICP备20003309号