除非我在某些"提供"之前添加@MainScope或@Singleton注释,否则该应用程序正常工作。方法,然后我得到gradle构建错误
错误:任务':app:kaptDebugKotlin'执行失败。 内部编译器错误。有关更多详细信息,请参阅日志
日志包含:
构建时间戳:本地:1508577084874,设备:1508577084874 2017-10-21 11:18:34,358 [216576] INFO - \ tools.idea.fd.InstantRunBuilder - BuildCause:FIRST_INSTALLATION_TO_DEVICE,BuildMode:FULL 2017-10-21 11:18:34,359 [216577] INFO - ild.invoker.GradleBuildInvoker - 即将执行Gradle任务:[:app:assembleDebug] 2017-10-21 11:18:34,377 [216595] INFO - s.plugins.gradle.GradleManager - 指示gradle使用来自C:/ Program Files / Java / jdk1.8.0_144的java 2017-10-21 11:18:34,408 [216626] INFO - util.EmbeddedDistributionPaths - 在' C:\ Program Files \ prebuilts \ tools \ common \ offline-m2'中寻找嵌入式Maven仓库。 2017-10-21 11:18:34,408 [216626] INFO - ild.invoker.GradleBuildInvoker - 构建命令行选项:[ - configure-on-demand,-Pandroid.injected.invoked.from.ide = true,-Pandroid .injected.build.api = 25,-Pandroid.injected.build.density = 560dpi,-Pandroid.injected.build.abi = x86,-Pandroid.injected.restrict.variant.name = debug,-Pandroid.injected.restrict .variant.project =:app,-Pandroid.optional.compilation = INSTANT_DEV,FULL_APK,-Pandroid.injected.coldswap.mode = MULTIAPK] 2017-10-21 11:18:34,420 [216638] INFO - xecution.GradleExecutionHelper - 将命令行参数传递给Gradle Tooling API: - configure-on-demand -Pandroid.injected.invoked.from.ide = true -Pandroid .injected.build.api = 25 -Pandroid.injected.build.density = 560dpi -Pandroid.injected.build.abi = x86 -Pandroid.injected.restrict.variant.name = debug -Pandroid.injected.restrict.variant.project =:app -Pandroid.optional.compilation = INSTANT_DEV,FULL_APK -Pandroid.injected.coldswap.mode = MULTIAPK 2017-10-21 11:18:36,975 [219193] INFO - roid.sdk.MessageBuildingSdkLog - com.android.ide.common.blame.Message。(com.android.ide.common.blame.Message $ Kind,java。 lang.String,java.lang.String,com.google.common.collect.ImmutableList) java.lang.NoSuchMethodException:com.android.ide.common.blame.Message。(com.android.ide.common.blame.Message $ Kind,java.lang.String,java.lang.String,com.google.common .collect.ImmutableList) 在java.lang.Class.getConstructor0(Class.java:3082) 在java.lang.Class.getConstructor(Class.java:1825) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper $ simpleMessageConstructor $ 2.invoke(KotlinOutputParserHelper.kt:171) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper $ simpleMessageConstructor $ 2.invoke(KotlinOutputParserHelper.kt:143) 在kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.getSimpleMessageConstructor(KotlinOutputParserHelper.kt) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.createNewMessage(KotlinOutputParserHelper.kt:272) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage(KotlinOutputParserHelper.kt:250) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage $ default(KotlinOutputParserHelper.kt:244) 在org.jetbrains.kotlin.android.KotlinOutputParserHelperKt.parse(KotlinOutputParserHelper.kt:66) 在org.jetbrains.kotlin.android.KotlinOutputParser.parse(KotlinOutputParser.java:28) 在com.android.ide.common.blame.parser.ToolOutputParser.parseToolOutput(ToolOutputParser.java:86) 在com.android.tools.idea.gradle.output.parser.BuildOutputParser.parseGradleOutput(BuildOutputParser.java:43) 在com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutor $ GradleTasksExecutorImpl.lambda $ collectMessages $ 5(GradleTasksExecutor.java:517) 在com.intellij.openapi.application.impl.ApplicationImpl $ 2.run(ApplicationImpl.java:342) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745) 2017-10-21 11:18:36,981 [219199] INFO - roid.sdk.MessageBuildingSdkLog - 来自KotlinOutputParser的异常 2017-10-21 11:18:36,983 [219201] INFO - roid.sdk.MessageBuildingSdkLog - com.android.ide.common.blame.Message。(com.android.ide.common.blame.Message $ Kind,java。 lang.String,java.lang.String,com.google.common.collect.ImmutableList) java.lang.NoSuchMethodException:com.android.ide.common.blame.Message。(com.android.ide.common.blame.Message $ Kind,java.lang.String,java.lang.String,com.google.common .collect.ImmutableList) 在java.lang.Class.getConstructor0(Class.java:3082) 在java.lang.Class.getConstructor(Class.java:1825) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper $ simpleMessageConstructor $ 2.invoke(KotlinOutputParserHelper.kt:171) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper $ simpleMessageConstructor $ 2.invoke(KotlinOutputParserHelper.kt:143) 在kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.getSimpleMessageConstructor(KotlinOutputParserHelper.kt) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.createNewMessage(KotlinOutputParserHelper.kt:272) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage(KotlinOutputParserHelper.kt:250) 在org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage $ default(KotlinOutputParserHelper.kt:244) 在org.jetbrains.kotlin.android.KotlinOutputParserHelperKt.parse(KotlinOutputParserHelper.kt:41) 在org.jetbrains.kotlin.android.KotlinOutputParser.parse(KotlinOutputParser.java:28) 在com.android.ide.common.blame.parser.ToolOutputParser.parseToolOutput(ToolOutputParser.java:86) 在com.android.tools.idea.gradle.output.parser.BuildOutputParser.parseGradleOutput(BuildOutputParser.java:43) 在com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutor $ GradleTasksExecutorImpl.lambda $ collectMessages $ 5(GradleTasksExecutor.java:517) 在com.intellij.openapi.application.impl.ApplicationImpl $ 2.run(ApplicationImpl.java:342) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745) 2017-10-21 11:18:36,983 [219201] INFO - roid.sdk.MessageBuildingSdkLog - 来自KotlinOutputParser的异常 2017-10-21 11:18:37,092 [219310] INFO - pl.ProjectRootManagerComponent - 项目根已更改 2017-10-21 11:18:37,108 [219326] INFO - a.gradle.run.MakeBeforeRunTask - Gradle调用完成,success = false 2017-10-21 11:18:37,195 [219413] INFO - .diagnostic.PerformanceWatcher - 推送属性需要8ms;一般回应:好的; EDT响应:好的 2017-10-21 11:18:37,334 [219552] INFO - .diagnostic.PerformanceWatcher - 可索引文件迭代耗时138ms;一般回应:好的; EDT响应:好的 2017-10-21 11:18:37,339 [219557] INFO - indexing.UnindexedFilesUpdater - 未加索引的文件更新已启动:要更新的8个文件 2017-10-21 11:18:37,556 [219774] INFO - .diagnostic.PerformanceWatcher - 未经索引的文件更新耗时217ms;一般回应:好的; EDT响应:好的
这是我的模块:
@Module
class MainModule(val activity: Activity) {
@Provides
fun providesContext(): Context = activity.baseContext
@Provides
fun providesActivity(): Activity = activity
@Provides
@MainScope
fun providesView(activity: Activity): MainActivityView = MainActivityView(activity)
@Provides
@MainScope
fun providesPresenter(view: MainActivityView): MainPresenter = MainPresenter(view)}
MainScope:
import javax.inject.Qualifier
import javax.inject.Scope
@Scope
annotation class MainScope
修改
MainComponent:
@Component(modules = arrayOf(MainModule::class), dependencies =
arrayOf(ApplicationComponent::class))
public interface MainComponent{
fun inject(activity: MainActivity)
}