gpt4 book ai didi

gradle - 无法解决 ':app@debugUnitTest/compileClasspath'、:app@debugAndroidTest/compileClasspath 的依赖关系

转载 作者:行者123 更新时间:2023-12-01 08:22:33 31 4
gpt4 key购买 nike

情况:

  1. 创建最简单的项目
  2. 作为文件添加到项目模块 -> 新建 -> 新模块“手机和平板电脑模块”
  3. 添加对模块的依赖

并得到错误:

无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析项目 :testmodule。

无法解析 ':app@debugAndroidTest/compileClasspath' 的依赖关系:无法解析项目 :testmodule。

无法解析 ':app@debugUnitTest/compileClasspath' 的依赖关系:无法解析项目 :testmodule。

无法解析 ':app@release/compileClasspath' 的依赖关系:无法解析项目 :testmodule。

无法解析 ':app@releaseUnitTest/compileClasspath' 的依赖关系:无法解析项目 :testmodule。

以下是项目文件:

项目:

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'


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

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

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

模块:应用程序

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.pawga.test00"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(path: ':testmodule')
}

模块:测试模块

apply plugin: 'com.android.application'

android {
compileSdkVersion 28



defaultConfig {
applicationId "com.pawga.testmodule"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

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

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

gradle-wrapper.properties

#Mon Jun 25 22:51:52 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

settings.gradle

include ':app', ':testmodule'

注意:如果模块类型为“Android Library”(上面点“二”),则不存在此类错误。

对于这样一个简单的项目,一切都是默认的,不应该出现这样的错误。怎么了?

最佳答案

试试这个,替换:

implementation project(':testmodule')

收件人:

implementation project(path:':testmodule', configuration: 'default')

关于gradle - 无法解决 ':app@debugUnitTest/compileClasspath'、:app@debugAndroidTest/compileClasspath 的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51031514/

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