Problem
Protobuf-generated sources are not resolved as Generated Sources:
and cannot be used in a different Gradle module. An error Cannot Resolve Symbol is shown
Solution
- Add the
ideaplugin to a Protobuf module build.gradle file with the configuration below:
sourceSets.main.java.srcDir new File(buildDir, 'generated')
idea {
module {
// Marks the already(!) added srcDir as "generated"
generatedSourceDirs += file('build/generated')
}
}
specified paths may vary depending on a project configuration.
-
Add
implementation project(':protobuf')dependency to a build.gradle file of a module where Protobug-generated sources are used. Ensure that a dependency is visible underFile | Project Structure | Modules | module_name | Dependencies -
Hit the
Reload All Gradle Projectsbutton in the Gradle tool window:
Comments
0 comments
Please sign in to leave a comment.