Android moves its own project to a new studio, causing strange errors

When we download other people's projects from github, we will re-download the Gradle files. In other words: We downloaded a new Android studio, and moving the original old project to the new Android studio will cause Gradle to be inconsistent with the current Gradle.

We know that there is no problem with the code, but the running environment is different.

First, create a new project and find out the version number and JDK

Create a new project and run it, you can find the version number of the project (under the Poject directory->build.gradle) and JDK
(check gradle in files->setting->Build, Execution, Deployment->Build Tools- >Gradle)

Attached are my version numbers (Figure 1):
figure 1
JDK and Gradle (Figure 2)
Insert image description here

The first step is to open the .gradle file in the root directory of the project that needs to be moved.

Find the file location of your original project, open the .gradle file, delete all the files inside, then copy the contents of your current .gralde file and paste it into your original project. This is the gralde of my original project.
Insert image description here
Find the project you just ran normally, open the gradle file, copy all the files, and paste them into the new .gradle.
Insert image description here

The second step is to open the build.gradle file (open with Notepad)

Insert image description here
Change the version to the version in Figure 1. I have already changed it here.
Insert image description here

The third step, open the gradle file, find and open the gradle-wrapper.properites file

Insert image description here

Insert image description here
Changing the path of distributionUrl to the gradle in Figure 1
Insert image description here
may cause you to re-download gradle, pause it, then set the relative path of gradle, and change the path of Gradle JDK to the version in Figure 2. Please see my other blog: Every time you create a new project, gradle will be re-downloaded

After these three steps of modification are completed, the project can be opened and run normally.

Guess you like

Origin blog.csdn.net/qq_62079241/article/details/131285799