New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:prepareKotlinBuildScriptModel Task fails in a Java project #14889
Comments
Hi @spectrumIG, |
@eskatos ok this is the log of the build:
BUILD FAILED in 12s Thanks a lot. |
@spectrumIG, is it happening when importing a subproject in your IDE or the whole build? Just trying to rule out some cases. Also, what version of the IntelliJ/Studio Kotlin Plugin do you have installed in your IDE? |
@eskatos it happens when building the whole project. Version are: Android Studio 4.1 (updated yesterday). Kotlin plugin -> 1.4.10-release-Studio4.1-1. Thanks |
Thanks. About the confusion, this task has nothing to do with the fact that your project doesn't have Kotlin sources. It's about supporting the edition of That task is always registered on the root project. The error message you get suggests that the IDE tries to execute it on the @NataliaUkhorskaya, any idea what could happen here? |
@eskatos Yes, I perfectly understand. Infact the strange thing that happens is that the SAME task runs smoothly,meaning doing absolutley nothing as expected, if the gradle and gradle plugin are mantained at previous versions. |
Hi @spectrumIG I think I have the same problem as you, did you fix it? How? |
@vladimirdolzhenko please take a look |
@KibiH actually I didn't. I simply downgrade Gradle version to 6.1.1 and Gradle Android plugin to 4.0.1 and the task suddenly start to pass again. |
@spectrumIG , do you observe the issue only if some preconditions are met (e.g. run from AS, do some steps) or one could just checkout source code and reproduce the issue? |
Same issue happening for me, Also had to downgrade to 4.0.2 Studio to make it work. 😢 |
@ausatiy I'm sorry but actually I don't know. I mean, I only tried with this project because is the only project i use at work which has java code. i mean, i didn't even try to put on an actual kotlin project. So, I'm sorry but I don't know. I'm quite sure that java language is a prerequisite though. |
Thank you. I've failed to reproduce the issue just by using Kotlin from master (~1.4.30, but it should not be quite different from 1.4.10 which is mentioned earlier) + AS 4.1 + Gradle 6.5 and quite simple Android+java project. |
Hey spectrumIG, |
Alright, I finally fixed the problem and got everything working in the newest versions! There were multiple build.gradle files in the Teapots sample, one for the main Teapots projects and more for the subprojects. I just opened the build.gradle for classic-teapot which was the subproject I was editing and added this line to the build.gradle file (not inside any other function, as its own function): |
@SamCarmichael36 Thank you so much😃 |
Could anybody reproducing this problem share a build and instructions to reproduce? |
No problem choheeis! eskatos: here is a link to the teapot sample I was using: |
Thanks @choheeis your fix also worked for me! |
Thank you @SamCarmichael36 for the reproducer. Unfortunately I can't reproduce with it. I was able to import the build in IntelliJ without any issue. |
Relevant comment on the corresponding Youtrack issue at https://youtrack.jetbrains.com/issue/KT-37892#focus=Comments-27-4474258.0-0
This seems to imply that the problem happens when you open a subproject in IDEA instead of the root project/settings. @ausatiy or @nskvortsov, any idea what could cause that in IDEA or its Kotlin plugin? |
Not sure about what is going on with the |
Shouldn't IDEA import the whole build when pointed at a subproject build script? This would prevent hard to troubleshoot issues. |
Thanks for trying it, eskatos. I'm surprised that it did not produce the same error, but I am using Android Studio in Ubuntu 20.04.1 LTS also. |
See: StackOverflow post solution Task 'prepareKotlinBuildScriptModel' not found in project ':app' |
Add this line to build.gradle file:
|
Adding the following to my
The solution from the previous comment only works for obsolete |
Same issue, still happened in gradle 7.3 with IDEA Intellij. Any update? |
In my case the problem was that I had a root Gradle project with multiple subprojects included in root's In other words: if you have a hierarchical Gradle project, make sure that when you open up the Gradle projects panel in IntelliJ, all subprojects are listed as children of the root. I had one subproject dangling, listed as sibling project of the root. I simply right clicked on it and chose "Unlink Gradle Project". IntelliJ automatically adds projects listed in |
Closing for now as no valid reproducer was shared and last comments indicate that this is an issue with opening a subproject directly in Idea. If you have a reproducer that points at a Gradle problem and is not caused by the above setup, please share and we can re-open. |
I'm having the same issue |
Me as well. I fixed it by deleting the unwanted GradleProjectSettings in the |
Thanks! Helped me! |
This solution helped me fix the same issue. Thanks a lot @ITachiLab! |
@spectrumIG So I got the same issue as yours. As the scenario is let my project name is ABC and the sub project name contains xyz. So I got this error when I import the sub project. After that I imported the ABC project and its perfectly synced. |
In my case, the following did not work :
So I disabled the Kotlin plugin, and the problem was solved. WARN! If you are using Android Studio, you should NOT disable the Kotlin plugin. (I'm on the latest IntelliJ 2023.1.1 Ultimate Edition.) |
Expected Behavior
With Android Studio 4.1 when updating to Gradle Plugin 4.1.0 and Gradle 6.5 I expect to build smoothly a previously building a full JAVA project
Current Behavior
When try to build an old Java project which build with previous configuration Gradle build starts to complain about a Gradle task :prepareKotlinBuildScriptModel which fails without any possibility of doing nothing
Context
I'm trying to build a normal non Kotlin project. The project is made by the app module and a second module which is a ndk/c++/java library. The project was perfectly building before updating plugin and Gradle versions.
Steps to Reproduce
-Take Android Studio 4.0 with plugin 4.0.1 and Gradle 6.1.
Your Environment
Android Studio 4.1, Gradle 6.5, Gradle plugin 4.1.0
S.O.: Ubuntu 20.04 LTS
The text was updated successfully, but these errors were encountered: