This problem sometimes occurs when opening Android files written by others:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.internal.application']
The solution is as follows:
1. In Project view mode, select gradle.properties file.
2. On the last line (or any line in the file), enter the following code.
android.overridePathCheck=true
This line of code means “overlay path checking”.
3. Then click ‘Sync Now’ in the upper right corner and wait a few seconds to solve the problem.