In the recent process of learning Android, I found that importing other people's projects was unsuccessful and reported various errors. After referring to other people's blogs, I recorded two solutions to the problem:
1. Gradle is different
(1) Open the folder of the android project as follows: first delete the three folders in the red box in the picture.
(2) We open the file build.gradle in the blue box: open a build.gradle file corresponding to the location of the android studio project created on our own machine, and then change the gradle version number of the imported project to the same as our own machine .
3. Copy the gradle folder in the project folder created by this machine to the project to be imported. Then import the project
2. SDK path problem
After the above settings, the following error occurred:
This is because the SDK path of the imported project is different from the local machine. Open the local.properties file in the local project folder:
change the following sdk directory to the corresponding file of the local machine project Sdk directory (no Chinese in the path).