I'm trying to develop an Android Compose project i...
# compose
p
I'm trying to develop an Android Compose project in IntelliJ IDEA. I tried creating a new project in AS and updating the gradle plugin to version 4.2.2 - after sync in IDEA everything works as expected. But in my actual project, the syntax highlighting doesn't work for any Compose code. The other Kotlin code highlighting/suggestions work fine, and the project also builds and runs fine. When I hover over any
@Composable
function, it shows the following:
Copy code
@[ERROR : Composable]
public fun Screen(): Unit
I didn't find any related errors in the gradle sync output, also filtering
idea.log
on the word
"compose"
didn't show anything interesting. What could be causing this problem? Is there a place where I can look for related logs?
c
AGP 4.2.2 is old no? Isn't 7.0+ the default now? I just created a new project on stable AS yesterday and had no issues. Let me check...
Yep. Latest stable AS, using the blank activity with compose template uses AGP classpath "com.android.tools.buildG7.0.4" and gradle
Copy code
gradle-7.0.2-bin.zip
Just make sure to use the latest AS and I think you'll be all set. (use jetbrains toolbox if you want to manage your downloads (its built with compose for desktop 😃
c
The problem is that 7+ is not compatible with IDEA but only Android Studio. And Compose needs the 7+ Gradle plugin to work properly.
p
@Colton Idle 4.2.2 is the latest version supported by IntelliJ IDEA, with any newer version sync doesn't work.
c
Any special reason @Philip Dukhov you are not using Android Studio?
p
@Chrimaeon I assume the Compose Multiplatform plugin might help. And the highlighting in a newly created project works fine, I wonder how.
@Chrimaeon I have a KMM project that includes a JVM based backend module. Inside this module I get an error
Unresolved reference for JVM classes
from the IDE, I already reported this AS issue. It's pretty weird since the error goes away and then comes back depending on AS or the kotlin plugin releases, not sure which ones, but it's still a problem with the latest versions. Inside IDEA I can develop my internal module with no problem, but I can't develop android. Also, there is noticeably less lag when working in IDEA.
👍 2
c
I see, I have the same problem with Kotlin multi platform projects. I guess the error is with caching of Gradle dependencies and so on. Cleaning the Gradle cache usually solves the problem for me.
If that does not work I have both AS and IDEA open at the same time - not good for memory consumption but solves the import issue 😅
c
I thought IDEA 2021.3 is supposed to have support for agp 7+?
j
@Philip Dukhov no that is untrue, latest idea supports gradle 7
🦜 3
p
wow, missed that, thanks @Colton Idle @Joost Klitsie!