Android Studio generated files in java folder after upgrading to AGP 8 + Gradle 8.0 + Kotlin 1.8.20

huangapple go评论80阅读模式
英文:

Android Studio generated files in java folder after upgrading to AGP 8 + Gradle 8.0 + Kotlin 1.8.20

问题

问题确切地如标题所述。Android Studio将Hilt和Glide生成的文件放在普通的java文件夹而不是java(generated)中,导致生成的文件和包与源文件并列。问题仅在1.8 Kotlin版本上发生。在此版本之前的所有版本都正常。我相信问题的根源是kapt,使用annotationProcessor会得到预期的结果。

英文:

The problem is exactly as said in the title. Android Studio is putting Hilt and Glide generated files in regular java folder instead of java(generated) leading to a lot of generated files and packages next to source files.

Problem occurs only on 1.8 Kotlin version. Everything prior to this version works fine. I believe that the root of the problem is kapt, using annotationProcessor leads to the expected result

答案1

得分: 2

Go to the Android Studio Settings and open this path like so:

Build, Execution, Deployment > Build Tools > Gradle

Change the Gradle JDK to the 11 version if it is 17 and press OK.

Roll back any changes in files that define the JDK version like misc.xml.

Clean your project using Build menu in the toolbar and Clean Project item and rebuild your project. It is also a good idea to Invalidate Caches and restart before build.

英文:

Go to the Android Studio Settings and open this path like so:

Build, Execution, Deployment > Build Tools > Gradle

Android Studio generated files in java folder after upgrading to AGP 8 + Gradle 8.0 + Kotlin 1.8.20

Change the Gradle JDK to the 11 version if it is 17 and press OK.
Roll back any changes in files that define the JDK version like misc.xml.

Clean your project using Build menu in the toolbar and Clean Project item and rebuild your project. It is also a good idea to Invalidate Caches and restart before build.

huangapple
  • 本文由 发表于 2023年4月19日 22:53:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76055945.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定