我的项目有两个项目:main project
和library project
.
main project
依赖library project
。_
现在我想同时使用kotlin
它们。我已将我的添加common rx extension code
到library project
:
fun String.rxRequest(@NotNull builder: (Request.Builder) -> Unit): Observable<Response> = Observable.create<Response> {
var mBuilder: Request.Builder = Request.Builder().url(this)
builder.invoke(mBuilder);
it.onNext(HttpClient.create().newCall(mBuilder.build()).execute())
it.onCompleted()
}.subscribeOn(Schedulers.from(THREAD_POOL_NET));
然后我在我的main project
:
"http://www.xxx.xxx".rxRequest {
val requestBody = FormEncodingBuilder().add("code", code).build()
it.post(requestBody)
.header("XRDid", appInfo.deviceId)
}
它构建失败:
LoginPresenter.kt: Unresolved reference: rxRequest
library project
构建成功,在构建文件夹中生成了 kotlin .class。
但main project
构建失败,构建文件夹中没有 kotlin .class 文件。