Android Studio Import Project very slow solution

Source: Internet
Author: User

Problem

Android Studio has now been updated to 2.0 Preview 6, and as a developer of Google's most respected development tool, there is an unparalleled advantage over eclipse ADT. However, in the actual use, there are still a lot of uncomfortable places. Android Studio native support using Gradle to build the project was a good idea, using dynamic language groovy to define the project build process and avoid the tedious definition of the Build.xml file. However, the Gradle binary package is large, and the user may follow a different version of Gradle, which can cause various problems when built. Therefore, Gradle wrapper was proposed to solve the problems that arose before. Gradle Wrapper is bound to a specified version of Gradle. When the user imports a project project, the Gradle package is automatically downloaded to the remote server. This solves the problem of client version inconsistency, but also brings a new problem: Domestic connection to remote server download Gradle package is very slow! So, whenever a new item is downloaded from GitHub and imported into Android studio, it will be stuck in this interface:

You don't know if it's as dead, or what it does in the background ... Either be resistant to the temper, or just turn off as, and it must be forced to close. This is a very unfriendly thing to do. In fact, the reason for this is that the Gradle package is downloaded from the server in the background. This Gradle package often has a few 10 trillion, in the network environment is not very good situation, it may take a long time to complete. Obviously, we don't have so much time to spend here, we need to find a way to solve it.

Workaround

On the web, it is common practice to modify the Gradle version in the Gradle wrapper configuration file, but none of them are complete. Finally, here we see the solution to the complete point. The following are some of the main steps to streamlining:

    1. First get the native related parameters, including the following (in parentheses is my own machine parameters):
      • Android Plugin Version: (1.5.0)

      • Gradle Version: (2.8)

      • Compile SDK Version: (All)

      • Build Tools Version: (23.0.2)

      • Gradlehome: (/applications/android studio.app/contents/gradle/gradle-2.8)

Getting the method is simple, create a new project in Android Studio, click on the project name right-select the "Open Module Settings" Pop-up dialog box to see:

2. When the parameters are ready, you can begin modifying the parameters of the target project. What files are the parameters that need to be modified?

      • xxx-project/.idea/gradle.xml File: Add or modify < option name = "Gradlehome" value />
      • xxx-project/gradle/wrapper/ Gradle-wrapper.properties file: distributionurl=https\://services.gradle.org/ distributions/gradle-gradleversion-all.zip
      • xxx-project/build.gradle file in front of: classpath ' Com.android.tools.build:gradle: Front android Plugin Version '   (This is the entire project configuration)
      • xxx-project/build.gradle file: Modify compile  Sdk version and build tools version parameter. (This is a single module configuration, and each module in project needs to be modified)

3. Modify the parameters and start importing the project formally. In general, this can be a smooth import into Android studio. If still stuck in the import interface, then only obediently wait ...

Reference
    • http://ju.outofmemory.cn/entry/229755
    • Https://docs.gradle.org/current/userguide/gradle_wrapper.html

Android Studio Import Project very slow solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.