Android – Kotlin – Dagger – No hay exception de método

Hoy creé un proyecto en el nuevo Android Studio Canary (beta). Traté de agregar el marco Dagger 2, pero tengo algunos problemas para hacer esto. Antes que nada, agrego algunas dependencies:

compile 'com.google.dagger:dagger:2.11' kapt 'com.google.dagger:dagger-compiler:2.11' provided 'org.glassfish:javax.annotation:10.0-b28' apply plugin: 'kotlin-kapt' (top of file) 

Y solo por las necesidades de mis testings y demás, creé class:

 class TempClass {} 

Luego hice un module de ejemplo

 @Module class TempClassModule { @Singleton @Provides fun provideTempClass() : TempClass = TempClass() } 

Y componente:

 @Component (modules = arrayOf(TempClassModule::class)) interface TempClassComponent { fun inject(mainActivity: MainActivity) } 

Mi class de aplicaciones:

 class MyApp : Application() { companion object { lateinit var tempComponent : TempClassComponent } override fun onCreate() { super.onCreate() prepareComponents() } fun prepareComponents():Unit { tempComponent = DaggerTempClassComponent.builder().build() } } 

Y actividad principal:

 class MainActivity : AppCompatActivity() { @Inject lateinit var tempClass : TempClass override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) MyApp.tempComponent.inject(this) } } 

Al comstackr el file gradle todo está bien. Pero cuando intenté rebuild el proyecto para que Dagger pueda comstackr libs, se produce un error:

 *Error:Execution failed for task ':app:kaptDebugKotlin'. > Internal compiler error. See log for more details* 

Y, por supuesto, la import de classs como DaggerTempClassComponent es imposible porque no existe. Cuando comento la línea con la variable en la class MainActivity todo va bien y hay DaggerTempClassComponent. ( //@Inject lateinit var tempClass : TempClass )

También revisé los loggings para ver qué está sucediendo, pero en mi opinión no hay mucho allí:

 2017-07-20 20:33:21,295 [se-884-b01] INFO - ild.invoker.GradleBuildInvoker - About to execute Gradle tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar] 2017-07-20 20:33:21,306 [thread 262] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/Home 2017-07-20 20:33:21,423 [thread 262] INFO - oject.common.GradleInitScripts - init script file sync.local.repo contents "allprojects {\n buildscript {\n repositories {\n maven { url '/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository'}\n }\n }\n repositories {\n maven { url '/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository'}\n }\n}\n" 2017-07-20 20:33:21,423 [thread 262] INFO - ild.invoker.GradleBuildInvoker - Build command line options: [--configure-on-demand, -Pandroid.injected.invoked.from.ide=true, -Pandroid.injected.generateSourcesOnly=true, --init-script, /private/var/folders/jh/wjxwkfzx2cgd0z5pqhksy_sw0000gn/T/sync.local.repo3273.gradle] 2017-07-20 20:33:21,423 [thread 262] INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: --configure-on-demand -Pandroid.injected.invoked.from.ide=true -Pandroid.injected.generateSourcesOnly=true --init-script /private/var/folders/jh/wjxwkfzx2cgd0z5pqhksy_sw0000gn/T/sync.local.repo3273.gradle 2017-07-20 20:33:23,196 [se-884-b01] INFO - ild.invoker.GradleBuildInvoker - Gradle build finished in 1s 888ms 2017-07-20 20:33:23,236 [se-884-b01] INFO - pl.ProjectRootManagerComponent - project roots have changed 2017-07-20 20:33:23,267 [thread 259] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:23,296 [thread 259] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 29ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:23,548 [se-884-b01] INFO - pl.ProjectRootManagerComponent - project roots have changed 2017-07-20 20:33:24,050 [thread 264] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:24,066 [thread 264] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 16ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:24,066 [thread 264] INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 7 files to update 2017-07-20 20:33:24,168 [thread 264] INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 102ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:27,871 [se-884-b01] INFO - ild.invoker.GradleBuildInvoker - About to execute Gradle tasks: [clean, :app:assembleDebug] 2017-07-20 20:33:27,876 [thread 264] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /Applications/Android Studio 3.0 Preview.app/Contents/jre/jdk/Contents/Home 2017-07-20 20:33:27,982 [thread 264] INFO - oject.common.GradleInitScripts - init script file sync.local.repo contents "allprojects {\n buildscript {\n repositories {\n maven { url '/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository'}\n }\n }\n repositories {\n maven { url '/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository'}\n }\n}\n" 2017-07-20 20:33:27,983 [thread 264] INFO - ild.invoker.GradleBuildInvoker - Build command line options: [--configure-on-demand, -Pandroid.injected.invoked.from.ide=true, --init-script, /private/var/folders/jh/wjxwkfzx2cgd0z5pqhksy_sw0000gn/T/sync.local.repo2419.gradle] 2017-07-20 20:33:27,983 [thread 264] INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: --configure-on-demand -Pandroid.injected.invoked.from.ide=true --init-script /private/var/folders/jh/wjxwkfzx2cgd0z5pqhksy_sw0000gn/T/sync.local.repo2419.gradle 2017-07-20 20:33:30,823 [thread 253] INFO - roid.sdk.MessageBuildingSdkLog - com.android.ide.common.blame.Message.<init>(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.<init>(com.android.ide.common.blame.Message$Kind, java.lang.String, java.lang.String, com.google.common.collect.ImmutableList) at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.getConstructor(Class.java:1825) at org.jetbrains.kotlin.android.KotlinOutputParserHelper$simpleMessageConstructor$2.invoke(KotlinOutputParserHelper.kt:171) at org.jetbrains.kotlin.android.KotlinOutputParserHelper$simpleMessageConstructor$2.invoke(KotlinOutputParserHelper.kt:143) at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.getSimpleMessageConstructor(KotlinOutputParserHelper.kt) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.createNewMessage(KotlinOutputParserHelper.kt:272) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage(KotlinOutputParserHelper.kt:250) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage$default(KotlinOutputParserHelper.kt:244) at org.jetbrains.kotlin.android.KotlinOutputParserHelperKt.parse(KotlinOutputParserHelper.kt:66) at org.jetbrains.kotlin.android.KotlinOutputParser.parse(KotlinOutputParser.java:28) at com.android.ide.common.blame.parser.ToolOutputParser.parseToolOutput(ToolOutputParser.java:86) at com.android.tools.idea.gradle.output.parser.BuildOutputParser.parseGradleOutput(BuildOutputParser.java:43) at com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutorImpl.lambda$collectMessages$5(GradleTasksExecutorImpl.java:487) at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:334) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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) 2017-07-20 20:33:30,824 [thread 253] INFO - roid.sdk.MessageBuildingSdkLog - Exception from KotlinOutputParser 2017-07-20 20:33:30,824 [thread 253] INFO - roid.sdk.MessageBuildingSdkLog - com.android.ide.common.blame.Message.<init>(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.<init>(com.android.ide.common.blame.Message$Kind, java.lang.String, java.lang.String, com.google.common.collect.ImmutableList) at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.getConstructor(Class.java:1825) at org.jetbrains.kotlin.android.KotlinOutputParserHelper$simpleMessageConstructor$2.invoke(KotlinOutputParserHelper.kt:171) at org.jetbrains.kotlin.android.KotlinOutputParserHelper$simpleMessageConstructor$2.invoke(KotlinOutputParserHelper.kt:143) at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.getSimpleMessageConstructor(KotlinOutputParserHelper.kt) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.createNewMessage(KotlinOutputParserHelper.kt:272) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage(KotlinOutputParserHelper.kt:250) at org.jetbrains.kotlin.android.KotlinOutputParserHelper.createMessage$default(KotlinOutputParserHelper.kt:244) at org.jetbrains.kotlin.android.KotlinOutputParserHelperKt.parse(KotlinOutputParserHelper.kt:41) at org.jetbrains.kotlin.android.KotlinOutputParser.parse(KotlinOutputParser.java:28) at com.android.ide.common.blame.parser.ToolOutputParser.parseToolOutput(ToolOutputParser.java:86) at com.android.tools.idea.gradle.output.parser.BuildOutputParser.parseGradleOutput(BuildOutputParser.java:43) at com.android.tools.idea.gradle.project.build.invoker.GradleTasksExecutorImpl.lambda$collectMessages$5(GradleTasksExecutorImpl.java:487) at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:334) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) 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) 2017-07-20 20:33:30,825 [thread 253] INFO - roid.sdk.MessageBuildingSdkLog - Exception from KotlinOutputParser 2017-07-20 20:33:30,831 [se-884-b01] INFO - ild.invoker.GradleBuildInvoker - Gradle build finished with 1 error(s) in 2s 948ms 2017-07-20 20:33:30,883 [se-884-b01] INFO - pl.ProjectRootManagerComponent - project roots have changed 2017-07-20 20:33:30,912 [thread 264] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:30,945 [thread 264] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 32ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:31,143 [se-884-b01] INFO - pl.ProjectRootManagerComponent - project roots have changed 2017-07-20 20:33:31,681 [thread 267] INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:31,706 [thread 267] INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 25ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:33:31,706 [thread 267] INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 2 files to update 2017-07-20 20:33:31,824 [thread 267] INFO - .diagnostic.PerformanceWatcher - Unindexed files update took 118ms; general responsiveness: ok; EDT responsiveness: ok 2017-07-20 20:37:26,379 [J pool 1/4] INFO - attrs.AttributeDefinitionsImpl - Found tag with unknown parent: AndroidManifest.AndroidManifestSupportsInput 2017-07-20 20:37:26,379 [J pool 1/4] INFO - attrs.AttributeDefinitionsImpl - Found tag with unknown parent: AndroidManifest.AndroidManifestCompatibleScreens 

Ejecutando ./gradlew build clean –stacktrace

 * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDebugKotlin'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:243) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:236) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:225) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: org.gradle.api.GradleException: Internal compiler error. See log for more details at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:9) at org.jetbrains.kotlin.gradle.internal.KaptTask.compile(KaptTask.kt:53) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:711) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:694) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) ... 27 more 

¿Alguien tiene una situación similar o tal vez sabe lo que está pasando? También descargué algunas aplicaciones de ejemplo con working dagger 2 con kotlin: todo se ve igual excepto la versión de idioma y funciona allí.

Android Studio Canary versión 7 Dagger 2 versión: 2.11 Versión de Kotlin: '1.1.3-2'

Sugerencia

  // download your android tools by SDK manager // v--------- check the version here compileSdkVersion 23// | buildToolsVersion "23.0.3"