2017-10-04 1 views
-1

단검의 파일을 생성하기위한 프로젝트를 빌드하려고하면 예외가 발생하여 빌드가 실패합니다. 수정 방법 또는 적어도 어떤 방향으로 보여 주시겠습니까?빌드 프로젝트 때 크래시 단검

e: /home/hodzi/Projects/StudioProjects/StackViewer/app/build/tmp/kapt3/stubs/debug/com/hodzi/stackviewer/di/AppComponent.java:6: error: [com.hodzi.stackviewer.questions.di.QuestionsComponent] com.hodzi.stackviewer.questions.di.QuestionsComponent has conflicting scopes: e:

e: public abstract interface AppComponent { e: ^e:
com.hodzi.stackviewer.di.AppComponent also has @Singleton e: java.lang.IllegalStateException: failed to analyze: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:57) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:138) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:58) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:103) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92) at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:386) at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:96) at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:889) at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:96) at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137) at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:916) at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:888) at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:385) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90) at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:42) at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:205) at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:166) at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:82) at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96) at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106) at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:83) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:377) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:68) at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:96) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:368) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:133) ... 30 more

요소 :

1) AppComponent

@Singleton 
@Component(modules = arrayOf(AppModule::class, NetModule::class)) 
interface AppComponent { 

    fun inject(app: App) 

    fun plus(questionsModule: QuestionsModule): QuestionsComponent 
} 

2) QuestionsComponent

@Singleton 
@Subcomponent(modules = arrayOf(QuestionsModule::class)) 
interface QuestionsComponent { 
    fun inject(questionsActivity: QuestionsActivity) 
} 

모듈 :

1) AppModule

@Module 
class AppModule(val application: Application) { 

    @Provides 
    @Singleton 
    fun provideApplication(): Context = application 

    @Provides 
    @Singleton 
    fun provideSharedPrefs(context: Context): SharedPreferences = 
      context.getSharedPreferences(context.packageName, Context.MODE_PRIVATE) 
} 

2) QuestionsModule

@Module 
class QuestionsModule { 
    @Provides @Singleton 
    fun provideQuestionsPresenter(questionsInteractor: QuestionsInteractor): QuestionsPresenter = 
     QuestionsPresenter(questionsInteractor) 

    @Provides @Singleton 
    fun provideQuestionsInteractor(api : Api): QuestionsInteractor = QuestionsInteractor(api) 
} 

앱 :

class App : Application() { 
    val appComponent: AppComponent by lazy { 
     DaggerAppComponent.builder() 
      .netModule(NetModule()) 
      .appModule(AppModule(this)) 
      .build() 

    } 

    val questionsComponent: QuestionsComponent by lazy { 
     appComponent.plus(QuestionsModule()) 
    } 

    override fun onCreate() { 
     super.onCreate() 
     Injector.inject(this) 
     NetUtils.init(this) 
    } 
} 

그 다음 도움이된다면 나는 githab

답변

2

당신 '에 대한 링크를 첨부 정의 됨 AppComponentQuestionsComponent을 모두 @Singleton으로 설정하면 어느 것이 해당 범위를 담당합니까? 그것이 바로 오류가 말하는 것입니다. 주석 중 하나에서 주석을 제거하십시오.

+0

하나의 싱글 톤을 제거 할 때 "(범위가 지정되지 않은) 범위가 지정된 바인딩을 참조하지 않을 수도 있습니다" –

+0

@Valeriy 따라서 사용자 정의 범위를 정의해야합니다. 당신이 따라하는 튜토리얼은 다음을 포함해야합니다. –