-
Notifications
You must be signed in to change notification settings - Fork 276
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
Android Studio with KSP: After changing kotlin code, the first assembleDebug task fails with compilation error, 2nd attempt always works fine but takes too long to build #1678
Comments
I am having a similar issue after migrating dagger to use ksp instead of kapt. My usual failing stack trace is the following:
I had your stack trace after migrating dagger to ksp but after the latest dagger release that is gone and this is the new error I am getting. The dagger team told me that since this is a ksp only stack trace I should file a bug with the ksp team. If you are using I suggest trying to upgrade dagger to the latest version but maybe you are getting your error without dagger. In any case I am also commenting to raise awareness of these issues |
I am experiencing something that seems related. I am using And I have many compilation failures (not always) that fail the first time (and works after building again):
I am using:
This is my environment:
|
I am experiencing this issue issue as well. I looked into the source code briefly and to me it seems that the cause of the issue this code snippet:
Because ksp calls this copyWithTimestamp function with the false overwrite parameter the copying of the file fails in case there is already an existing file there. As you can see if the dst (destination) is a file and it exists then the if statement will get called and the copying will fail. This causes the build to fail but after one failing build probably gradle empties the cache or some of the build folders so the next one will be successful because the file got deleted. In my opinion the overwrite parameter of the copyWithTimestamp function should be true in this case to resolve this. Although I am not yet a contributor to the ksp project and I am hoping someone who is more expert in the inner workings of ksp will take a quick look at this bug. I might open up a small pr about this if I have the time but I am not 100% sure that what I am proposing is the best solution to the issue |
Just commenting again to mention that the issue is the same with KSP2 and also to raise awareness to this issue which is really annoying and most likely easily fixed. However when I tried to open a pr about it I did not have the necessary permissions and the contribution guide is not clear about how to actually become a contributor so I could not open a pr (but maybe I am missing something). |
Seeing the same
|
I'm on Kotlin 2.0.0, KSP 2.0.0-1.0.24 (the same is reproducible with 2.0.20-RC and 2.0.20-RC-1.0.24), and Dagger 2.52, and I'm now having the same/similar issue:
The "duplicated class" is found in 3 places:
Other details:
The only "workaround" that I found is to set |
Regarding FileAlreadyExistsException and Dagger: It happened to one of our files after switching from kapt to ksp, and I managed to fix it in our project by doing 2 things:
Hope that helps someone. |
@ting-yuan Edit: Published a patch of the suggested change to |
Actually, I think applying that recommendation is only solving the symptom, not the problem. The actual problem is that since the The final file is determined in For example, the first compilation might create Inspecting our build after the error occurs in our project shows that our
and each round contains the offending file, even though the |
We're facing the same issue as well, the workaround is to disable |
We've encountered a similar issue in our project. Invoking Disabling |
Hey @jonamireh, thanks so much for the insight above! this is the offending line that you noted in your first comment, correct? This is my first time investigating the KSP source so it may be a naive approach, but this issue has been plaguing my team for quite awhile so I added a PR addressing the symptom that you talked about here, which makes sense to me looking at the point where the exception seems to get thrown (Windows example). If you have any more insight on the ultimate source problem from your discussion here please let me know; I'll continue digging into the source to see if I can find the originating problem. |
After upgrading to Android Studio Hedgehog | 2023.1, AGP to 8.2.0, kotlin to 1.9.21 and ksp to 1.9.21-1.0.16 I started to experience following behaviour of IDE:
As a result, what would take a couple of seconds to compile and run has become apprx 2 minutes between each code changes.
Changing XML code works fine. Incremental build is fast and no problems there. After AS Patch 1 was released with AGP 8.2.1 and kotlin 1.9.22 with corresponding ksp version, the problem is still there.
I would appreciate any help in resolving this problem. Developer experience is now very low and it is getting hard to be productive at work. Is there any settings I'm missing or should I reinstall the macOS and AS all together?
Compilation error stack trace shows different things but this one below is the most frequent among them.
My system info:
The text was updated successfully, but these errors were encountered: