gpt4 book ai didi

java - Gradle 搜索 Ivy 服务但未定义 Ivy 配置/ repo

转载 作者:太空宇宙 更新时间:2023-11-03 13:24:37 24 4
gpt4 key购买 nike

我从 Gradle 收到以下错误

Could not resolve all dependencies for configuration ':unitTestCompile'.> Could not find junit:junit:4.11.

Here is my build.gradle

apply plugin: 'android-library'buildscript {    repositories {        mavenCentral()    }    dependencies {        classpath 'com.android.tools.build:gradle:0.8.+'    }}version = '0.6.2'configurations {        unitTestCompile.extendsFrom runtime        unitTestRuntime.extendsFrom unitTestCompile}dependencies {    compile files('libs/android-support-v4.jar')    unitTestCompile 'junit:junit:4.11'}android {    buildToolsVersion "19.0.1"    compileSdkVersion 17     sourceSets {        main {            manifest.srcFile 'AndroidManifest.xml'            java.srcDirs = ['src', 'bundled-src']            resources.srcDirs = ['src']            aidl.srcDirs = ['src']            renderscript.srcDirs = ['src']            res.srcDirs = ['res']            assets.srcDirs = ['assets']        }    }    dependencies {        compile fileTree(dir: './libs', include: 'Amplitude.jar')    }}sourceSets {        unitTest {                java.srcDirs = ['tests/src']                res.srcDirs = ['tests/res']                assets.srcDirs = ['tests/assets']                resources.srcDirs = ['tests/res']        }}task doUnitTest(type:Test, dependsOn: assemble) {        description = "run unit tests"        testClassesDir = project.sourceSets.unitTest.output.classesDir        classpath = project.sourceSets.unitTest.runtimeClasspath}check.dependsOn doUnitTest

A debug run indicates that it is trying to resolve the dependency with Ivy and not with Maven?


16:21:58.633 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration :analytics-android:0.6.2(unitTestCompile).
16:21:58.633 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency :analytics-android:0.6.2(unitTestCompile) -> junit:junit:4.11(dependency: junit#junit;4.11 {unitTestCompile=[default]})
16:21:58.634 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Selecting new module version junit:junit:4.11
16:21:58.634 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module 'junit:junit:4.11' using repositories []
16:21:58.636 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching :analytics-android:0.6.2(unitTestCompile) to its parents.
16:21:58.637 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in /private/var/folders/7y/yrtq1vcx3xb901v_xd5v5_100000gn/T/gradle1413382664789288993.bin. Wrote root :analytics-android:0.6.2:unitTestCompile.
16:21:58.638 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':compileUnitTestJava'
16:21:58.638 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :compileUnitTestJava (Thread[main,5,main]) completed. Took 0.017 secs.
16:21:58.639 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 4.035 secs, idle: 0.047 secs
16:21:58.644 [ERROR] [org.gradle.BuildExceptionReporter]
16:21:58.645 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:21:58.645 [ERROR] [org.gradle.BuildExceptionReporter]
16:21:58.646 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:21:58.646 [ERROR] [org.gradle.BuildExceptionReporter] Could not resolve all dependencies for configuration ':unitTestCompile'.
16:21:58.646 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find junit:junit:4.11.
16:21:58.646 [ERROR] [org.gradle.BuildExceptionReporter] Required by:
16:21:58.647 [ERROR] [org.gradle.BuildExceptionReporter] :analytics-android:0.6.2

最佳答案

问题是您只为构建脚本依赖项声明了一个存储库,而没有为常规依赖项声明一个存储库。 (换句话说,您需要一个顶级 repositories block 。)此外, dependencies block 应该始终位于 android block 之外,因为它是与 Android 插件无关的核心 Gradle 功能。

关于java - Gradle 搜索 Ivy 服务但未定义 Ivy 配置/ repo ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22310637/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com