This issue happened when the Java project has some protobuf definition file and the corresponding generated Java class could not be found in the Java classes, even the whole project could be compiled properly by “gradle clean build” command. The root cause was that, the IDE(IntelliJ IDEA) could not find the Java source code generated by the protobuf compiler although the Java source code was generated already.
The solution is simple. Go to “File -> Project Structure -> Project Settings -> Modules”, in the existing default module, select “main”, click the “+ Add Content Root” link. In the pop-up file selector window, select the “<project_root>/build/generated/source/proto” directory which contains the generated Java classes. After that, the IDE can find the Java classes and the Java files depending these classes can be compiled correctly.