Android Studio 3.0.1 无法将 android-library 依赖项添加到 java-library 模块

Android Studio 3.0.1 failed to add android-library dependency to java-library module

我有以下项目结构:

我想添加一个数据模块依赖(数据模块是android-lib)到域模块(域模块是java-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
}

我不明白这里到底出了什么问题以及为什么我的项目无法构建。

UPDsettings.gradle

include ':presentation', ':data', ':domain'

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