【问题标题】:Gradle is not searching for packages in local Maven repository. How to fix?Gradle 不在本地 Maven 存储库中搜索包。怎么修?
【发布时间】:2022-01-17 16:46:34
【问题描述】:

这是我的根 build.gradle 文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenLocal()
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

当我尝试运行 ./gradlew :app:compileDebugKotlin 时,我得到了这个:

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.neborosoft.AndroidJniBridgeGenerator:annotations:1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/neborosoft/AndroidJniBridgeGenerator/annotations/1.0/annotations-1.0.pom
       - https://repo.maven.apache.org/maven2/com/neborosoft/AndroidJniBridgeGenerator/annotations/1.0/annotations-1.0.pom
       - https://jcenter.bintray.com/com/neborosoft/AndroidJniBridgeGenerator/annotations/1.0/annotations-1.0.pom
     Required by:
         project :app > project :Logic

如您所见,它不会尝试在本地 Maven 存储库中进行搜索。你知道怎么解决吗?

【问题讨论】:

    标签: android maven gradle


    【解决方案1】:

    buildscript 子句仅用于解析插件(及其依赖项)。在buildscript 之外添加另一个repositories 子句,如下所示:

    buildscript {
        repositories {
            mavenLocal()
            ...
        }
        ...
    }
    repositories {
        mavenLocal()
        ...
    }
    

    【讨论】:

    • 请分享完成的 build.gradle 文件
    【解决方案2】:

    放置您的:

    mavenLocal()
    

    在应用程序的 gradle 文件中

    【讨论】:

      猜你喜欢
      • 2015-02-23
      • 2019-01-17
      • 2015-08-27
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多