Intereting Posts
Kotlin: метод не может использоваться с дженериками Странная ошибка «Val не может быть переназначена» при установке свойства в Kotlin объекта Java Истребитель Котлин перечислить? Как обрабатывать ошибки записи в Apache Jena? Spring Boot ThymeLeaf и Kotlin – значение флажка не передается контроллеру? Что означает смысл в котлине? Свойства делегата Kotlin, реализующие функцию оператора «предоставлятьDelegate», но метод никогда не вызывал Есть ли какая-нибудь библиотека для работы с монадами на котлин? Kotlin + MVP – случайное переопределение Ошибка ': android: transformKotlinClassesWithJillForDebug'. При создании приложения для Android, написанного в Kotlin + LibGDX Ячейки RecyclerView деформируются при открытии клавиатуры Как использовать Spring Data JPA методы, возвращающие поток в блок try-with-resources в Котлине? Анимация просмотра путем масштабирования до полной высоты экрана от его положения Изменить поведение List.get в Котлине Проверьте, нет ли функции в Котлине

Android – Kotlin – Dagger – Нет такого исключения метода

Сегодня я создал проект в новом Android Studio Canary (бета). Я попытался добавить рамки Dagger 2, но у меня возникли некоторые проблемы. Прежде всего, я добавляю некоторые зависимости:

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) 

И только для нужд моего тестирования и т. Д. Я создал класс:

 class TempClass {} 

Затем я сделал примерный модуль

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

И компонент:

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

Мой класс приложения:

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

И Основная деятельность:

 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) } } 

При компиляции файла gradle все в порядке. Но когда я попытался перестроить проект, чтобы Кинжал мог создавать библиотеки, возникает ошибка:

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

И, конечно, импортировать классы, такие как DaggerTempClassComponent , невозможно, потому что их не существует. Когда я комментирую строку с переменной в классе MainActivity все идет хорошо, и есть DaggerTempClassComponent. ( //@Inject lateinit var tempClass : TempClass )

Я также проверил журналы, чтобы узнать, что происходит, но, на мой взгляд, там не так много:

 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 

Запуск ./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 

Кто-нибудь имел подобную ситуацию или, может быть, знал, что происходит? Я также загрузил несколько примеров приложения с рабочим кинжалом 2 с kotlin – все выглядит одинаково, кроме языковой версии, и там работает.

Android Studio Canary релиз 7 Dagger 2 версия: 2.11 Kotlin версия: '1.1.3-2'

Предложение

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