Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
791 views
in Technique[技术] by (71.8m points)

android - ERROR : error.NonExistentClass Kotlin In multi module Dagger project

I'm using Dagger 2 and Kotlin for Android development. My project is also a multi-module project. My settings.gradle file is like this:

include :app
include :lib

I'm also maintaining the lib module.

In the Dagger Files (for example in the component), I try to get the item from other module. For example:

@Component
interface AppComponent{
    fun getPresenter() : Presenter
}

The Presenter object is defined in lib module. I was working in linux environment and I'm using Android Studio 3 preview canary 5. The code is working well and I am able to generate APK.

But my company wanted to generate the APK using stable version of Android Studio. I'm using Android Studio 2.3.3.

When compiling the Android Project, I encountered this error:

error: error.NonExistentClass

The error appears when

:app:kaptDebugKotlin 

is performed and caused by the dagger class cannot found, the class is defined in the other project. What can be the possible workaround for this? Sorry for my bad English.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just add this to build gradle file to avoid the issues related NonExistentClass

kapt {
    correctErrorTypes true 
} 

https://kotlinlang.org/docs/reference/kapt.html#non-existent-type-correction


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...