google / google/protobuf-gradle-plugin
Generated java sources are not automatically visible to Android Studio
- Dominant language
- Groovy
- Stars
- 1.8k
- Forks
- 288
- PR merge metrics
- No merged PRs in 30d
Description
When generating java sources from protobuf via Gradle, the (re-)generated sources do not automatically become a part of Android Studio's source model. A file system refresh ("Reload from disk"/"Synchronize external changes") or project sync is necessary before references to these generated sources stop showing errors in the IDE editor.
It may seem a simple step to manually refresh in a simple project, but it can quickly turn into a non-obvious issue among many others in a not so simple project. In my experience of many years Android Studio does not tend to behave in a particularly robust manner when it comes to non-Android code, generated in various semi-supported and non-trivial scenarios, e.g. non-Android projects or modules, Kotlin multi-platform projects, etc.
To clarify where I'm coming from, I was essentially unable to use IDE editing support entirely for a long time for some code depending on protobuf in a slightly more complex Android Studio library project. This was just one of various IDE-related issues in the project, some of which were caused by unsupported scenarios. Recently "something" changed to the point where I am able again to leverage IDE benefits for editing the protobuf-related Kotlin sources (fingers crossed). Except I did not notice initially, as I did not manually reload/sync after generating java from protobuf. So while I held some hope that "something" would resolve the editing issues, I initially wrote it off because this secondary (decidedly more trivial) issue of manual syncing obscured my vision.
TL;DR addressing this issue in some way would be helpful for eliminating a headache and see other problems more clearly. Maybe something else can be done via the `idea` plugin that I could add myself? The README implies that the protobuf plugin already applies proper configuration for `idea`; I did not have any better luck with additional `idea` configuration.
I tested this on the `helloworld` grpc-java Android example project with various recent versions Android Studio, Gradle, and protobuf plugin. On Intel Mac. The problem can be reproduced out of the box with the most recent `helloworld` sources from grpc-java 1.51.1.
Contributor guide
Assessment
This issue has not been assessed yet.