There are two possible cases of error: Java: compilation failed: internal java compiler error.
1. The JDK version may be inconsistent
Check whether the following three parts are consistent.
Preferences -> Compiler -> Version setting SDK version in Java compiler
File -> Project Structure -> SDK version in project
File -> Project Structure -> Module -> Module SDK version in each module dependencies
2. The memory setting of the compilation environment may be insufficient.
Preferences -> Compiler -> Shared build process heap size
Increase the default memory of 700M.