apollographql / apollo-kotlin

:rocket:  A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform.
https://www.apollographql.com/docs/kotlin
MIT License
3.75k stars 652 forks source link

Unresolved reference apollo3.gradle.api in custom gradle plugin #4729

Closed ProVir closed 1 month ago

ProVir commented 1 year ago

Version

3.7.4

Summary

Hi!

I wrote my plugin and there is a problem.

The Apollo classes are not visible in Android Studio, but everything is compiled correctly.

I have been observing the problem since 3.0.0.

image

Steps to reproduce the behavior

Example Project: ApolloPluginTest.zip

Logs

No response

martinbonnin commented 1 year ago

Thanks for the reproducer. Will check this out! Can I ask for your Android Studio version?

martinbonnin commented 1 year ago

Alright, I can reproduce with

Android Studio Electric Eel | 2022.1.1 Patch 2
Build #AI-221.6008.13.2211.9619390, built on February 17, 2023
Runtime version: 11.0.15+0-b2043.56-8887301 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 10
Registry:
    external.system.auto.import.disabled=true
    ide.text.editor.with.preview.show.floating.toolbar=false

Non-Bundled Plugins:
    com.intellij.marketplace (221.6008.18)
    com.jetbrains.codeWithMe (221.6008.13.5)
martinbonnin commented 1 year ago

It's working fine with Android Studio Girafe 2022.3.1 Canary 7 and IntelliJ 2023.1 EAP so I'm going to assume this will fix itself automatically in a few months.

apollo-gradle-plugin is the relocated jar so looks like there's something in the relocation that Android Studio didn't like. If it's too much of an issue for you and you can't switch to a Canary version, you can use apollo-gradle-plugin-external and plugin id com.apollographql.apollo3.external that has external bundling. Let me know if you see anything we can do, if not I'll close this issue.

ProVir commented 1 year ago

The problem has been reproduced since version 3.0.0 and Android Studio of those versions (a year and a half ago). All this time the problem did not disappear and decided to highlight it.

At the moment, this is not a big problem, but it really hinders any changes in the future (you have to write blindly).

But now working through apollo-gradle-plugin-external has helped me - this is already a solution that helps in the moment, thank you!

If the problem disappears in future versions of Android Studio, it will be cool, then you can close the issue.

martinbonnin commented 1 year ago

Marking this one as blocked. Let's try again when Flamingo goes stable.

martinbonnin commented 1 year ago

Just tried with Studio Flamingo | 2022.2.1 Patch 2 and it's still happening :(. But Android Studio Hedgehog | 2023.1.1 Canary 9 is working. So looks like we'll have to wait for Giraffe to go stable.

martinbonnin commented 1 month ago

Working as of Android Studio Koala | 2024.1.1 Patch 1

Screenshot 2024-08-13 at 12 59 43