Android Studio Stuck at Gradle Download on create new project

后端 未结 17 1734
盖世英雄少女心
盖世英雄少女心 2020-12-02 04:01

I have installed the new Android Studio. Everything was working fine but when I try to create a new project it gets stuck at downloading Gradle

17条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 04:48

    Note : My answer seems quite long but its only 2 steps away if you want a correct way to configure with current project.

    I found what was the actual problem. Actually, each android project comes with its own version of gradle wrapper.

    have a look at dir

    projectname/gradle/wrapper

    here the properties file says the version of gradle that this project uses:

    #Mon Sep 08 13:53:18 PDT 2014
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
    

    So the issue is if you dont have that version of gradle then it will download that version for you. For instance have a look at this dir, where it downloaded gradle versions for me

    /home/myusername/.gradle/wrapper/dists

    looks like

    Here it will try to download version of gradle if you dont have. If you are comfortable with downloading other version of gradle then you can wait till it completes else

    Workaround will be: 1. if project is on git clone it first.

    1. goto your projectdir/gradle/wrapper

    3.change version of distributionUrl to version that you already have : eg: for 2.2.1-all

    url will be

    distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

    4.copy gradle-wrapper.jar to your projectdir/gradle/wrapper from

    .gradle/wrapper/dists/gradle-2.1.1-all/4ryh47z6pv2tj9n03uiw8pzc6/gradle-2.2.1/lib/gradle-wrapper.jar(dont forget to rename gradle-wrapper2.2.1.jar to gradle-wrapper.jar)

    1. now import your project in studio.. and it works.

提交回复
热议问题