Android库模块在使用纯Kotlin模块的类时不会编译

我有一个使用这个结构的项目: https : //github.com/android10/Android-CleanArchitecture ,我试图把它转换成Kotlin。

域模块编译得很好,但是当我尝试编译数据模块时,出现以下错误:

Unresolved reference: ThreadExecutor` 

和其他一些类似的错误。

这些错误是关于接口,dataclass或匕首单身人士。 看来,数据模块无法从域模块中找到一些对象(尽管IntelliJ在编辑器中没有显示任何错误)。

这是ThreadExecutor接口:

 package com.company.app.domain.executor import java.util.concurrent.Executor interface ThreadExecutor : Executor 

域模块build.gradle文件:

 apply plugin: 'java' apply plugin: 'kotlin' //noinspection GroovyUnusedAssignment sourceCompatibility = JavaVersion.VERSION_1_7 //noinspection GroovyUnusedAssignment targetCompatibility = JavaVersion.VERSION_1_7 buildscript { repositories { mavenCentral() } } dependencies { testCompile 'junit:junit:4.12' compile 'io.reactivex.rxjava2:rxjava:2.1.3' compile 'io.reactivex.rxjava2:rxkotlin:2.1.0' compile 'com.google.guava:guava:22.0-android' compile 'javax.inject:javax.inject:1' compile 'joda-time:joda-time:2.9.9' } repositories { mavenCentral() } compileKotlin { kotlinOptions { jvmTarget = "1.6" } } compileTestKotlin { kotlinOptions { jvmTarget = "1.6" } } 

全球项目build.gradle文件:

 // Top-level build file where you can add configuration options common to all sub-projects/modules. apply plugin: 'kotlin' buildscript { ext.kotlin_version = '1.1.4-3' repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { jcenter() mavenCentral() } configurations.all { resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1' } } clean { delete rootProject.buildDir } 

最后是数据模块build.gralde:

 buildscript { repositories { mavenCentral() } } apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { publishNonDefault true compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { minSdkVersion 23 targetSdkVersion 26 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_7 targetCompatibility JavaVersion.VERSION_1_7 } } dependencies { compile project(':domain') compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.1.3' compile 'io.reactivex.rxjava2:rxkotlin:2.1.0' compile 'com.google.code.gson:gson:2.8.1' compile 'com.squareup.okhttp3:okhttp:3.8.1' kapt 'com.google.dagger:dagger-compiler:2.11' compile 'com.google.dagger:dagger:2.11' androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.0.0-alpha1' testCompile 'junit:junit:4.12' } repositories { mavenCentral() } 

看起来像Kotlin编译的域名jar不会像数据模块期望的那样公开这些对象,但是我现在还不知道为什么。

Kotlin language will be the best programming language for Android.