我有以下项目结构:

我想在域模块(域模块是java-lib)中添加一个数据模块依赖(数据模块是android-lib)。当我这样做的时候,我收到了这样的消息:

这是我的domain\build.gradle文件:
apply plugin: 'java-library'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':data')
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"和data\build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//<!-- RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.7'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
testImplementation 'org.robolectric:robolectric:3.5.1'
//<!-- OrmLite
implementation 'com.j256.ormlite:ormlite-core:5.0'
implementation 'com.j256.ormlite:ormlite-android:5.0'
//<!-- XStream
implementation ('com.thoughtworks.xstream:xstream:1.4.10') {
exclude group: 'xmlpull', module: 'xmlpull'
}
//<!----SLF4J
implementation 'org.slf4j:slf4j-api:1.7.21'
//<!-- RetroFit
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
}最后是整个项目的build.gradle:
buildscript {
repositories {
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}我不明白这里到底出了什么问题,为什么我的项目不能构建。
更新settings.gradle
include ':presentation', ':data', ':domain'发布于 2018-01-25 16:28:40
presentation依赖于domain吗?如果是这样的话,您需要使data也成为presentation的依赖项,或者在domain build.gradle中使用api project(':data')而不是implementation project(':data')。
这是因为implementation不会将其依赖项泄漏给依赖它的模块,而api会。因此,在您的配置中,presentation看不到data。有关官方文档的更多信息,请单击此处https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations
https://stackoverflow.com/questions/48437888
复制相似问题