Android Studio import too slow Modify the project configuration file and import it again, it feels like flying

Have you ever had the experience of copying a project
on [Github] or from someone else, but it couldn’t be compiled for a long time, the progress bar kept spinning, and there was no prompt to tell us what the specific error was, and the heart was broken.

I have roughly summed up the use of Android Stuido to load a project. The required environment includes:

  1. Gradle, including Gradle usage version and Android plugin version
  2. JDK, which is required for all Java programs
  3. Compile Sdk – Android SDK required
  4. Build Tool—Build Tool
  5. Numerous third-party packages


According to my observation, the slow loading speed of Android Studio is mostly caused by [Gradle] . Why do you say that? Because there is an error elsewhere, the compiler will prompt for example:
use Java8 to compile the code, but in my environment only Java6 and Java7 do not have Java8, and soon the compiler will prompt, as follows
at a glance , the prompt says that I do not have Java8, or Add Java8 support, or remove sourceCompatibility JavaVersion.VERSION_1_8;
but he is meow, if Gradle is missing, there is no prompt, or it can be said that the prompt error is like this
or like this
, believe it or not, if he waits for it to load by itself, his [progress bar] I can give you half a year… The most crashed one has no prompt, no prompt, no prompt. If the user doesn’t have much experience, he doesn’t even know why, stupid wait… Like Me is actually broken inside. I thought AS had suspended animation…
In fact, this is still to blame for our special network environment in China. Here is a solution: http://www.androiddevtools.cn/ , download the domestic mirror and configure it manually. But we’re talking about another way today that doesn’t require a download:

Modify Gradle version and AndroidStudio plugin version

Let’s take a project as an example. I just downloaded a project from Github. Let’s modify the project configuration file according to the 5 items I just mentioned to use Android Stuido to load a project’s required environment.

Modify Gradle version

Download the project:
After decompressing ImageCompare-master, manually modify the Gradle version, the configuration file location is
ImageCompare-master/gradle/wrapper/gradle-wrapper.properties, and the part that is framed in red on the picture At
this time, you will ask, how do I know, modify it to How many.

Mac system defaults to: /Users/ (username) /.gradle/wrapper/dists/ 
Windows system defaults to: C:\Users\(username)\.gradle\wrapper\dists\

This is the directory for my personal computer, I develop on Mac myself, and the company develops on Windows, all two environments need to be configured
We see that what I need is version 2.2, but I don’t have this version in my computer ( 2.2.1 is not version 2.2 ), so loading the project will be very slow, and directly modify it to version 2.13 (as long as you have it in your directory, You can download the complete version, or you can manually download and copy it here).

Default location not found .gradle

Don’t worry, we can also get it back through Android Studio
Open Android Studio, go to Preferences in Settings/Mac in Windows, search for gradle, follow the steps, the red box is your configuration address

Modify the Gradle plugin version

gradle plugin, declared in the project: ImageCompare-master/build.gradle
Inside the red box is, the version you need to modify it, how much is modified?
Open AndroidStudio and find a successfully compiled project: then his File –> project structure –> project
2.1.2 is the current version of his plugin, modify it

In fact, Gradle has been modified, it is almost the same, of course, if you want to be faster

a little faster

Modify Java version, Build Tool, Android Build Sdk

Location, there is a module file under each project file, this file corresponds to each Android App or Library, and there is a build.gradle file under them, indicating the configuration required to compile the App.
This project: ImageCompare-master/ Open
app/build.gradle and take a look. It is the parameter in the red box. It can be modified to the available value. Or open File –> project structure –> project in AndroidStudio, and select a part of the Module red box in his Modules. The value in the drop-down box is what we need, modify it.

Modify the version of the third-party library

It is generally not recommended to modify, because the differences between each library of the third-party library may be relatively large, the modification location is in the .gradle file.

Mac system defaults to: /Users/ (username)/.gradle/caches/modules -2 /files -2.1 
Windows system defaults to: C:\Users\(username)\.gradle\caches\modules -2 \files -2.1

Take mine as an example,
1. Open a com.squareup.okhttp3 folder at random, the files under the okhttp3 package are all here.
2. Then there is a subfolder of logging-interceptor, open it and there are 3.0.1; 3.1.2; 3.3.1;
3. For example, what I import now is

compile 'com.squareup.okhttp3:logging-interceptor:3.0.2'

I have every reason to modify him to:

compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'

In this way, it will not be downloaded when loading, and the local package will be loaded directly to improve the loading speed of the project.

Leave a Comment

Your email address will not be published. Required fields are marked *