A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
See original GitHub issueIf I write code like this by mistake:
class Fragment {
companion object {
@Inject
lateinit var viewModelFactory: ViewModelFactory
}
// the viewModelFactory injection should by in Fragment code block, not in companion object block
}
Then the Android Studio will build failed, only show “A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution”; even I execute “./gradle assembleDebug --statcktrace”. There is no further more infomation.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:14 (1 by maintainers)
Top Results From Across the Web
A failure occurred while executing org.jetbrains.kotlin.gradle ...
In Android studio go to Analyze menu and click on Inspect Code; check whole project, click OK and wait for the inspection to...
Read more >A failure occurred while executing org ... - JetBrains YouTrack
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException (no error message) ...
Read more >Kotlin 1.7.0 - A failure occurred while executing org.jetbrains ...
Execution failed for task ':presentation:kaptDebugKotlin'. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.
Read more >A failure occurred while executing org.jetbrains.kotlin.gradle ...
Android : A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution java.lang.reflect.
Read more >A failure occurred while executing org.jetbrains.kotlin.gradle ...
Recently I got this error :. A failure occurred while executing org.jetbrains.kotlin.gradle.internal.kaptexecution. ? How can I solve this ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My solution was just adding those lines to
gradle.properties
Ok, so I figured my issue out and wanted to share with everyone just in case you experience the same issue. Basically, this most likely means you have a dependency in your Gradle module that your app module doesn’t know about. So for example you may have the following setup, which Hilt supports.
In api, you may have a class and module like this
This is all fine, and accomplishes your goal of having a singleton for your OKHttp client for use in other parts of your app. The problem comes now, your app module which contains all of the hilt checks and final setup doesn’t know of this code, it has no clue what OkHttp is.
You can fix this compile error by either setting implementation into api, so that it becomes a transitive dependency, disable transitive dependency validation, or add the dependency as implementation() to your app module. I personally did the last option, as api() was causing slower builds for us.