Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details
Asked Answered
C

43

269
Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details

build:gradle(Module:app)

buildscript {
    repositories {
        maven {
            url 'https://jitpack.io'
            url 'https://maven.fabric.io/public'
        }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android-extensions'


repositories {
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    useLibrary 'org.apache.http.legacy'

   

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

    defaultConfig {
        applicationId "uxx.xx.xxe"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 17
        versionName "0.1.14"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            ext.enableCrashlytics = false
            debuggable true
            minifyEnabled true
            shrinkResources true
            
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
            assets.srcDirs = ['src/main/assets', 'src/main/assets/']
            res.srcDirs = ['src/main/res', 'src/main/assets/fonts']
        }
    }

    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"

    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/ECLIPSE_.SF'
        exclude 'META-INF/ECLIPSE_.RSA'
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile "com.android.support:cardview-v7:${rootProject.supportLibraryVersion}"
       compile "com.google.android.gms:play-services-ads:${rootProject.googlePlayServicesVersion}"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile 'org.igniterealtime.smack:smack-android-extensions:4.1.9'
    compile 'org.igniterealtime.smack:smack-tcp:4.1.9'
    compile 'org.igniterealtime.smack:smack-experimental:4.1.9'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.getkeepsafe.dexcount'

build:gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.2-2'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'com.google.gms:google-services:3.0.0'
        //visualize the method count
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

ext.googlePlayServicesVersion = '10.2.0'
ext.supportLibraryVersion = '25.3.1'

task clean(type: Delete) {
    delete rootProject.buildDir
}

Solution Tried:

  1. Invalidate Caches/Restart
  2. Build -> Clean Project
  3. Update kotlin plugin, used lastest version of kotlin, google APIs.

EDIT

./gradlew build --stacktrace > logs.txt 2>logErrors.txt

logErrors.txt

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    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:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    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.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
    at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
    at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
    at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:8)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.processCompilerExitCode(Tasks.kt:286)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:260)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:163)
    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:123)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
    ... 70 more
Centering answered 8/5, 2017 at 13:21 Comment(12)
Can you also post whatever is in the log?Lusatian
hey, sorry. Actually I don't know where I should look for log. Can you help me that also @LusatianCentering
@Lusatian I have look up in under message section but there is no log availableCentering
@Lusatian I have added the logCentering
You should probably file an issue in the Kotlin bugtracker.Florentinaflorentine
@Ankur_009, I have same issue. Did you find solution?Racket
did you tried the option that I have mentioned in the question? @SattarHummatliCentering
Yes, i've tried. The same result. @CenteringRacket
I don't know specifically what was the reason but I had created the new project. But I think it occurs when copy another project activity class to the new project. Try to restart the system (lame answer. as I don't know the exact solution) @SattarHummatliCentering
I ran into this problem today. Doing a Gradle clean then restarting Android Studio seemed to resolve the issue.Consist
Sometimes may help to update gradle version in gradle-wrapper.properties fileFingering
When I ran the build again, it worked, per this question: https://mcmap.net/q/110768/-java-rmi-unmarshalexception-error-unmarshaling-return-header/897007Candlelight
J
247

I got such error after a simple try of code refactoring. It has happened nor after some library was connected neither any changes in gradle. It looked like something in my code was wrong but the compiler could not find the issue. That's why I double checked all changes that I did and found that I had somehow changed method signature in the interface but had not changed it in class that implements it. I got this error twice during one day and decided to share my experience. I hope that it is a temporary compiler bug.

Solution 1 Possible solution is to go to File -> Settings -> Build, Execution, Deployment --> Compiler -> and add "--stacktrace --debug" to Command-line Options. Read log and try to found the answer of what went wrong.

In new Android Studio 3.1.+, you can enable/disable console log details by pressing "Toggle View" on "Build" tab. There you can find the details. Pay attention that both modes can be useful for investigation of the problem's reason. See: https://stackoverflow.com/a/49717363/

enter image description here

Solution 2 Click on Gradle (on the right side bar) then under :app choose assembleDebug (or assembleYourFlavor if you use flavors). Error will show up in Run tab. See: https://stackoverflow.com/a/51022296

Solution 3 As a last resort. In the android studio, try Code -> Inspect Code -> Whole project > Done. Wait until the inspection is over and then correct errors in "General" section and possible ones in other sections.

Note The kapt3 can be a source of such bugs. I removed apply plugin: 'kotlin-kapt' and added kapt { generateStubs = true } into android {} section of build.gradle. It seems that the previous version of the kapt generator is bugs free. (Update. It looks like a bug with kapt is gone on kotlin version 1.2.+)

Jeer answered 10/7, 2017 at 15:54 Comment(13)
@newbie I hope one day we will get updates with fixes for such issues.Jeer
I have try moving to backward, I back to use apply plugin: 'kotlin-kapt', and my android studio back get error. but I try debug with terminal like this ./gradlew build I have no error, and compile is successful. hmmm it's very weird.Federalize
I mean why android studio and terminal making different of result? and what code android studio to compile gradle?Federalize
@Federalize it's difficult to find out why this happens. I have an explanation for all cases: android always contain a piece of magic =)Jeer
Well this solution in last Update somewhat works for me. remove the kotlin-kapt and add in kapt{generetaStubs = true}Intermit
The original (old) kapt is deprecated and will be removed completely soon after Kotlin 1.2. If you experience any problems with apply plugin: 'kotlin-kapt', please file an issue to kotl.in/issue.Mammilla
@Mammilla After the original kapt will be removed we will see how the new one will work. Maybe problem will gone at all with this update.Jeer
@Mammilla It looks like truth. With kotlin v1.2+ and new kapt I have not faced such issue for a long time.Jeer
Tried Solution 1. Nothing came in log and still issue persists.Compliment
@MalwinderSingh Check the updated answer. AS 3.1 can be the reason why you do not see log details.Jeer
@IgorGanapolsky In android studio try Analyze -> Inspect Code -> Whole project. Wait until inspection is over and then correct errors in "General" section.Jeer
I am using Android studio 3.3 and kotlin version 1.3.20 Solution 3 helped me. Thanks so much.Kokanee
Weird...simply adding the compiler flags "fixed" the problem for me...Unstop
S
118

I had misleading error messages similar to the ones posted in the question:

Compilation error. See log for more details

And:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
    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.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    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:248)
    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:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
    at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:16)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.processCompilerExitCode(Tasks.kt:429)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:390)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:274)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:233)
    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 org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    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:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 32 more

Solution:

I solved it by

  1. Clicking on Gradle (on the right side bar) ->
  2. Then under :app
  3. Then choose assembleDebug (or assembleYourFlavor if you use flavors)

In Picture:

1 & 2:

s1

3:

s2

Error will show up in Run: tab.

Selfseeker answered 25/6, 2018 at 11:21 Comment(7)
Thank you. Found the issue using this. One thing to note, is that the original gradle error that doesn't help much shows up first when scrolling back through the logs, keep scrolling back and you will find the original error. Easily identifiable by the blue link to the source file causing the issue.Foust
I don't see "assembleDebug" if listSherleysherline
"./gradlew assembleDebug" at the project root will do the jobMorita
@user7856586 me too, did't find assembleDebugMicturition
@VikasPandey I forgot how I solve this problem. Maybe it's depends on AS versionSherleysherline
":app/Tasks/other/assembleDebug" is the current pathPines
Perfect solution!Donndonna
T
106

If you are using AS 3.1 the new build graphical console isn't very helpful for finding out the source of the problem.

you need to click on toggle view and see the logs in text format to see the error and if needed to Run with --stacktrace

enter image description here

Terranceterrane answered 8/4, 2018 at 11:31 Comment(9)
Thanks!! I had to do this after a couple of hours of debugging.. one thing I want to add to your answer is that the error might be some lines above the one that contains the "Compilation error. See log for more details" message.Avouch
thanks! it's more explicit to see the text errors. after hours of debugging, I found the right error. For me it was because of the @inject of the viewModel, I forgot to put the annotation on the viewModel constructor alsoInference
Funny enough, this is the only way to catch Dagger-related error. Ridiculous!Theocracy
Thank you so much for this answer. I found that I forgot to import Log inside LoggingInterceptor.Hedvah
An IDE as failed as an IDE if it's unable to convey compilation errors to the developer. Seriously Google: Work weekends until this is fixed.Materials
thank you! thank you! thank you! @Terranceterrane this led me to the right path :)Samantha
@Materials I second that, and please change the tool windows back to the bottom. It is really annoying to have to do a treasure hunt for logcat.Dorothydorp
@Materials It's not Google responsibility area. It's Jetbrains bug.Jeer
Thank you! Console view helped me, in graphical view I had 2 warnings, whether in console view I have 2 warning + 1 error, which was what I was looking for.Forefoot
U
38

This error shows up when there is Kotlin Compilation Error.

Run the below command to find where there is Kotlin Compilation Error,

gradlew clean assembleDebug (for Windows)
./gradlew clean assembleDebug (for Linux and Mac)

It will show you the exact location on which line there is Kotlin Compilation Error.

Upperclassman answered 6/7, 2019 at 9:20 Comment(4)
this one helped! thanksIrregularity
Yep, this told me the exact error!Killebrew
It worked for me, thanks a lot!! THe problem was something with versionsIslander
Best solution for multi-module app.Hyperbolize
H
18

On Mac :

go to Android Studio > Settings > Build, Execution, Deployment > Gradle-Android Compiler

On Windows :

go to File > Settings > > Build, Execution, Deployment > Compiler

Now, in the Command-line Options field , add following three flags :

--stacktrace --info --scan

like shown below

enter image description here

Now , open the Build window from the bottom of Android studio enter image description here

Then, there is a button on the left side of the Build window:

enter image description here

press this button , you will see detailed logs with exact code that is preventing the project from compiling

Hearty answered 9/9, 2018 at 11:7 Comment(0)
U
17

1 - Check if kotlin version is same across project

Declare this in your project level gradle file

buildscript {
ext {
    kotlin_version = '1.5.10'
}

And make sure kotlin gradle plugin has the same version

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

2 - Run build with parameters like --stacktrace --debug --info --scan one by one

Read the error carefully and check if it mentions any of your files

3 - Export logs from build and read them

Run this command

./gradlew build --stacktrace > logs.txt 2>logErrors.txt

4 - Inspect Code And Fix Any Problems You May Find

Go to Analyze -> Inspect Code in Android Studio

5 - Invalidate Caches , Clean & Rebuild Project

If this does not fix your problem , you might have a dependencies issue , check them carefully , make your 1 is satisfied with all dependencies

Uncovenanted answered 1/8, 2021 at 9:7 Comment(2)
my case ,i ve just update to : ext.kotlin_version = '1.3.50'Excavator
in my case, running ./gradlew build --scan revealed the error: e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.7.10 which is not known to be compatible.Tjon
F
14

In such case look at gradle console it will show the issue in detail with exact location which led to this compilation error.

In my case I was using Butterknife in one of my class and I had auto-converted that class to kotlin using android studio's utility

Log in Gradle Console

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
:app:buildInfoDebugLoader
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: /Users/Downloads/myproject/app/google-services.json
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:kaptGenerateStubsDebugKotlin
Using kotlin incremental compilation
:app:kaptDebugKotlin
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ConfirmationDialog.java:10: error: @BindView fields must not be private or static. (com.myproject.util.ConfirmationDialog.imgConfirmationLogo)
e: 

e:     private android.widget.ImageView imgConfirmationLogo;
e:                                      ^
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ConfirmationDialog.java:13: error: @BindView fields must not be private or static. (com.myproject.util.ConfirmationDialog.txtConfirmationDialogTitle)
e: 

e:     private android.widget.TextView txtConfirmationDialogTitle;
e:                                     ^
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ConfirmationDialog.java:16: error: @BindView fields must not be private or static. (com.myproject.util.ConfirmationDialog.txtConfirmationDialogMessage)
e: 

e:     private android.widget.TextView txtConfirmationDialogMessage;
e:                                     ^
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ConfirmationDialog.java:19: error: @BindView fields must not be private or static. (com.myproject.util.ConfirmationDialog.txtViewPositive)
e: 

e:     private android.widget.TextView txtViewPositive;
e:                                     ^
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ConfirmationDialog.java:22: error: @BindView fields must not be private or static. (com.pokkt.myproject.ConfirmationDialog.txtViewNegative)
e: 

e:     private android.widget.TextView txtViewNegative;
e:                                     ^
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ExitDialog.java:10: error: @BindView fields must not be private or static. (com.myproject.util.ExitDialog.txtViewPositive)
e: 

e:     private android.widget.TextView txtViewPositive;
e:                                     ^
e: /Users/Downloads/myproject/app/build/tmp/kapt3/stubs/debug/com/myproject/util/ExitDialog.java:13: error: @BindView fields must not be private or static. (com.myproject.util.ExitDialog.txtViewNegative)
e: 

e:     private android.widget.TextView txtViewNegative;
e:                                     ^
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:144)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:167)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
    at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:182)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.execCompiler(CompileServiceImpl.kt:397)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$execCompiler(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:365)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:798)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:825)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$checkedCompile(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:797)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:791)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$doCompile(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:364)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:336)
    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:346)
    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.resolve.jvm.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:89)
    at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:99)
    at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:76)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.analyze(KotlinToJVMBytecodeCompiler.kt:365)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:105)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:354)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:139)
    ... 40 more


 FAILED
:app:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 32s

16 actionable tasks: 7 executed, 9 up-to-date

As in my log it clearly shows issues are with declaration of variables with butterknife. So I looked into this issue and was able to solve it.

Filter answered 10/7, 2017 at 11:57 Comment(4)
In my opinion it's better to use kotlin extensions instead of butterknife. But nevertheless thanks for sharing your experience. It can be helpfull for many people.Jeer
@Jeer kotlin supports many of the android frameworks now thats why I gave it a try look at kotlinlang.org/docs/tutorials/android-frameworks.htmlFilter
You are right! But if we talking exactly about view initialization by @BindView in butterknife I discovered that kotlin extensions provide much more easy way to get views instances in code. Just take a look, you'll love it) kotlinlang.org/docs/tutorials/android-plugin.htmlJeer
@Jeer Thanks for the link it's a lot easier than butterknife.Filter
W
9

I changed my project to use Androidx, so I used the migration tool but some files(many files), didn't change automatically. I opened each file (activities, enums, fragments) and I found so many errors. I corrected them but the compile still show me incomprehensible errors. After looking for a solution I found this answer that someone said:

go to Analyze >> Inspect code

enter image description here

Whole Project:

enter image description here

It took some time and then showed me the result below:

enter image description here

As I corrected the errors I thought were important, I was running the build until the remaining errors were no longer affecting the build.

My Android Studio details

enter image description here

Waldrup answered 22/8, 2019 at 1:58 Comment(0)
B
7

I had a similar problem. The problem was that I incorrectly wrote the properties of the model in the attributes of the view:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@{ferm.coin.value}"/> 

This part was wrong:

@{ferm.coin.value}

When I wrote the correct property, the error was resolved.

Basseterre answered 8/8, 2017 at 18:25 Comment(0)
U
6

Please upgrade your kotlin version in your Gradle file to

ext.kotlin_version = '1.5.10'
Uppercase answered 30/9, 2021 at 11:22 Comment(0)
I
6

For me, updating the kotlin version to the latest in app level build.gradle file and then syncing the project worked.
So the gradle file looks like the following (at the time of writing the answer):

buildscript{
    ...
    ...
    dependency{
        classpath "com.android.tools..."
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
    }
}
Insincere answered 12/11, 2021 at 14:11 Comment(1)
That's the answer. In my experience, falling back to version 1.5.10 from 1.6.0 solve the problemClavius
M
5

I was suffering the same problem I solved it by checking build tab and switch to text mode. Check the console it will show the problems mine was removing a drawable without deleting the usage and deleting a class without deleting the usage also Text mode button

Mismatch answered 3/3, 2018 at 21:5 Comment(0)
T
4

in my case I accidentally changed version="1.0" to xml version="1.0" in my XML file.

I only had to change it back.

if you have the same problem and the solutions above didn't work for you. open Gradle Console and scroll to Run with --debug option click it and it will show you more useful info about your error.

some notes:

this error doesn't appear directly after I make the change in XML it appear only after I change some java code. I think it has something to do with the instant run and build cash.

Terranceterrane answered 28/7, 2017 at 17:55 Comment(0)
R
4

This line work for me on mac or Linux.

./gradlew clean assembleDebug
Rhoden answered 8/1, 2019 at 9:8 Comment(0)
F
4

I have found one solution to this problem.

Please follow below these steps:

  1. Go to File->Settings->Compiler->add To --stacktrace --debug in Command-line-Options box and then apply & ok.
  2. Rebuild a project.
  3. Run a project.
Faints answered 9/3, 2019 at 8:48 Comment(0)
P
3

I want to add my solution to above, maybe it helps someone. When i create a field on a model via Room and do not generate getter/setter for the field. As a result project is not compiling and no clear errors.

Pillsbury answered 21/12, 2018 at 13:17 Comment(0)
N
3

I faced the similar problem in no reason, i think it was caused by IDE(android studio). I have tried all of above solutions but not worked. Finally, in my own situation, i solved this problem by the following actions: - Close the current project and remove it from the list of projects in android studio ,and reopen it by Open an existing Android Studio project, then it may be worked. I hope that my experience will be useful for you.

Narcotism answered 9/4, 2019 at 7:34 Comment(0)
I
2

I Had the same issue and finally discovered the reason. In my case it was a badly written Java method:

@FormUrlEncoded
@POST("register-user/")
Call<RegisterUserApiResponse> registerUser(
        @Field("email") String email,
        @Field("password") String password,            
        @Field("date") String birthDate,
);

Note the illegal comma after the "date" field. For some reason the compiler could not reveal this exact error, and came with the ':app:compileDebugKotlin'. > Compilation error thing.

Importunate answered 16/11, 2017 at 6:34 Comment(0)
J
2

upgraded Android Studio from 3.2.1 to 3.3 and the problem disappeared

Johnnyjohnnycake answered 21/1, 2019 at 11:8 Comment(0)
U
2

in my case:: I was using kotlin extensions to access and bind my views, I had recently moved a view to another screen and forgot to remove its reference from the previous fragment that caused this error.

kotlin synthetic extensions are not compile time safe. I really loved this but apparently in big projects, if this happens again I'm surely going to get a heart attack.

Unconformity answered 16/6, 2019 at 15:33 Comment(0)
R
2

run gradle assembleDebug --scan in Android studio Terminal, in my case I removed an element in XML and forgotten to remove it from code, but the compiler couldn't compile and show Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details to me.

enter image description here

Resorcinol answered 7/7, 2020 at 9:1 Comment(1)
since I don't have gradle on my path in windows, I was able to use the gradle wrapper instead: gradlew assembleDebug --scan. This helped me see the error output that wasn't showing in my build log. Took about 5 minutes to runFess
S
2

I had the same error, and it was related to Kotlin and java files with the same name.

The issue appeared after I converted a java file to kotlin in one branch, and then merged my branches, but both files remained in the project.

The error didn't show the duplicated file name, but after adding

kapt.incremental.apt=false to "gradle.properties" as suggested by this article:

Storebought answered 25/5, 2021 at 12:58 Comment(1)
Great, but please use the Code Sample format button ({}) for code pasting for better readability. Thanks.Judaist
B
2

If you are experiencing this error, it is because your build.gradle file is missing the kotlin plugin, most answers recommend changing the kotlin version but in some cases, you don't even see the plugin under dependencies, maybe it's a react native thing since I experienced it with react native.

Go to your_project -> android -> build.gradle file and inject the kotlin dependency with the code below under dependencies

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21"

replace the 1.7.21 at the end with the latest version of kotlin.

Your buildscript should look like the code below

buildscript {
ext {
    buildToolsVersion = "30.0.2"
    minSdkVersion = 21
    compileSdkVersion = 30
    targetSdkVersion = 30
    ndkVersion = "21.4.7075529"
}
repositories {
    google()
    mavenCentral()
}
dependencies {
    classpath("com.android.tools.build:gradle:4.2.2")
    classpath 'com.google.gms:google-services:4.3.5'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21" // change 1.7.21 to the latest kotlin version
}

}

Betook answered 9/11, 2022 at 13:38 Comment(0)
M
1

I had a same problem. To solve this problem just open your all files(recent working files) in Which you made the changes and check did you forget to delete some which should be deleted.

In my case the problem was with the Unreferenced code which I was using in one of my file and that code is present in that file which should not be present in that file because I was using an interface which I have deleted from my project but I forget to deleted from one of my file).

Magree answered 5/10, 2017 at 13:21 Comment(0)
A
1

In my case, I attempted to upgrade play_servicesand firebase versions to 15.0. Going back to 11.4.2 fixed my issue...

Ahmad answered 30/4, 2018 at 15:39 Comment(0)
S
1

My scenario:

old Kotlin dataclass:

data class AddHotelParams(val destination: Place?, val checkInDate: LocalDate,
                      val checkOutDate: LocalDate?): JsonObject

new Kotlin dataclass:

data class AddHotelParams(val destination: Place?, val checkInDate: LocalDate,
                      val checkOutDate: LocalDate?, val roundTrip: Boolean): JsonObject

The problem was that I forgot to change the object initialization in some parts of the code. I got a generic "compileInternalDebugKotlin" error instead of being told where I needed to change the initialization.

changing initialization to all parts of the code resolved the error.

Stingy answered 3/8, 2018 at 15:36 Comment(0)
E
1

In my case I forgot to add the return type to a function in my inherited class from RoomDatabase:

abstract class LocalDb : RoomDatabase() {
    abstract fun progressDao(): ProgressDao
}

The ProgressDao return type was missing.

Engorge answered 30/4, 2020 at 21:40 Comment(0)
P
1

Go to Gradle > your_project > app > Tasks > Build > assembleAndroidTest Run it and see what is the problem

enter image description here

In my case it was: enter image description here

Upgrading version fix the problem:

composeOptions {
    kotlinCompilerExtensionVersion '1.3.0'
}
Peyter answered 22/10, 2022 at 18:38 Comment(0)
I
1

I faced the same problem with 3 errors (flamingo version)

- Task :app:kaptGenerateStubsDebugKotlin FAILED
- A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWo
rkers$GradleKotlinCompilerWorkAction
- Compilation error. See log for more details

I've tried clean project, rebuild and validate cache and still. I used inspect tool to get all the warnings but i confused from the number of warnings.

my solution was to comment every file in kotlin and resources and let only MainActivity then run the code and that worked very very well then began to uncomment file after another till I found the problem was in navigation file include an argument with a different package name (when I moved the data class to another package it didn't change in navigation file so caused the error)

Interlay answered 21/12, 2023 at 14:4 Comment(0)
K
0

Another possible recent solution is changing gradle version to:

classpath 'com.android.tools.build:gradle:3.0.0-rc2'

and updating build tool

Knitted answered 21/10, 2017 at 14:3 Comment(0)
G
0

In my case error was caused by this line

@BindColor(R.color.colorAccent) var mColor: Int? = 0

Solved By

@JvmField @BindColor(android.R.color.white) @ColorInt internal var mColor: Int = 0

Error in GradleConsole

:app:kaptDebugKotlin e: \app\build\tmp\kapt3\stubs\debug\MainFragment.java:23: error: @BindColor field type must be 'int' or 'ColorStateList'. (com.sample.MainFragment.mColor) e:

e: private java.lang.Integer mColor;

Geoponic answered 20/2, 2018 at 10:36 Comment(0)
U
0

i was surprised to find that when i had a class that was closed it produced this vague error. changing it to a open class resolved the issue.

before:

 class DefaultSubscriber<T> : Observer<T> {//...
}

after:

open class DefaultSubscriber<T> : Observer<T> {//...
}
Unscientific answered 31/3, 2018 at 16:33 Comment(0)
C
0

Below changes worked for me

I change distribution URL, located in gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

And

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }

kotlin version 1.2.71

Collinear answered 24/10, 2018 at 7:11 Comment(0)
B
0

If you have Hilt in your app. Make sure you have annotated your module class with

@Module
@InstallIn(SingletonComponent::class)
class AppModule
Bans answered 28/2, 2021 at 14:47 Comment(0)
G
0

I'm migrating an old personal project and this message appeared. I was using AS 4.2 stable and removing the compose buildFeature solved the issue.

Guenther answered 3/7, 2021 at 19:23 Comment(0)
B
0

If you are having this issue when you are trying to run the app for the first time on a Physical Device: Check you have enabled USB debugging in mobile settings(visible in Developer options). and also install via USB option. Later allow the permissions.

Biometry answered 7/9, 2021 at 13:6 Comment(0)
E
0

Adding additional code to the mainactivity of my Flutter project caused me to have a similar problem. kt file by accident, thus I believe you might have made a mistake in mainactivity. kt so compiler throws this instead of compiling the code: exception in app:compileDebugKotlin

Evetteevey answered 19/7, 2022 at 12:32 Comment(0)
A
0

Just had the same error after upgrading to Android Studio Giraffe Canary 3. I am using JetpackCompose.

What worked for me is changing the kotlin version from id 'org.jetbrains.kotlin.android' version '1.6.21' apply false to id 'org.jetbrains.kotlin.android' version '1.6.10' apply false within the build.gradle project file

buildscript {
    ext {
        ...
    }



}
plugins {
    ...
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}```
Atlantean answered 9/2, 2023 at 21:42 Comment(0)
A
0

This error occurred when I migrated my Java files to kotlin. Few things to look for:

In your build.gradle file (app level) make sure you have kotlin plugin support

plugins {
   ...
   id 'org.jetbrains.kotlin.android'
}

android {
   ...
   kotlinOptions {
      jvmTarget = '1.8'
   }
}

In you build.gradle file (Top Level) make sure you have this

plugins {
   ...
   id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
}

If not working, Check out this answer too

Avenue answered 13/6, 2023 at 11:23 Comment(0)
E
0

Only and Only switch from java 8 to java 11

Eun answered 5/1 at 3:25 Comment(0)
V
0

enter image description here

after that enter image description here

./gradlew clean assembleDebug
Verlinevermeer answered 6/3 at 16:31 Comment(0)
A
0

I encountered a similar issue while attempting to merge two branches. The following steps resolved the issue for me:

  1. Build -> Clean Project
  2. Build -> Rebuild Project
Annunciate answered 19/3 at 4:14 Comment(0)
A
-6

In my case, this worked:

flutter create .
Aphesis answered 2/7, 2021 at 11:28 Comment(2)
the question is about a Kotlin Android Project not Flutter.Merla
Flutter can use Kotlin for Android dev.Endpaper

© 2022 - 2024 — McMap. All rights reserved.