解决Android Studio Unexpected tokens (use ; to separate expressions on the same line)

解决Android Studio Unexpected tokens (use ; to separate expressions on the same line)

王先生
2024-06-20 / 0 评论 / 9 阅读 / 正在检测是否收录...

较高版本 gradle 添加第三方仓库报错。

Android Studio Unexpected tokens (use ; to separate expressions on the same line)

解决办法

gradle 工程结构发生了变化,仓库添加由原来的 build.gradle 改到了 setting.gradle (kts 同理)。
jitpack 为例,将maven { url 'https://jitpack.io' }改为maven { url=uri("https://www.jitpack.io")}

官网给出的配置是

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }

应改为

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url=uri("https://www.jitpack.io")}
    }
}

rootProject.name = "HandHeldFixedPointWifi"
include(":app")

重新同步,解决

评论 (0)

取消