Initializing Gradle is taking forever on android studio for Flutter project

前端 未结 7 2275
遇见更好的自我
遇见更好的自我 2021-01-03 22:16

I\'m trying to run a hello world flutter app for the first time on my device, but when I hit run on android studio, it shows initilizing gradle, and it stays like that for m

相关标签:
7条回答
  • 2021-01-03 22:51

    The problem is that Gardle is downloading dependencies and not using any way to show progress(This is NOT good for UX), so it is better to run gradlew.bat in the terminal and things will become more clear, like this:

    Now it is much better, You can have a cup of coffee while watching it ;)

    0 讨论(0)
  • 2021-01-03 22:57

    https://github.com/flutter/flutter/issues/15106

    Please note riftninja's answer. I look at this directory: C:\Users\myname.gradle\wrapper\dists Yes, the gradle file is really big: 87M. You have to wait for a long time. After this will be "Resolving dependencies....", which also slowly. But finally it succeed.

    0 讨论(0)
  • 2021-01-03 22:59

    When running flutter project first time even correct configuration it takes very long time. That is because of downloading gradel and dependencies for particular version.If you ar noob Wait it to complete automatically till all files get downloaded. By using command:

    • flutter run <project-name> -v you can see whats happening in background.

    • To Manually downloading gradle zip and put to suitable directory. Go in Project Dir: /android/gradle/wrapper/gradle-wrapper.properties and click on url and download it.

    • After Downloading it visit to :/Users//.gradle/wrapper/dists/gradle-4.10.2-all/9fahxiiecdb76a5g3aw9oi8rv your version path may vary and paste downloaded zip inside it.
    • For Dependencies to download you need to wait depending on Internet speed.
    • It is one time process until next updated version and dependencies come UP.
    0 讨论(0)
  • 2021-01-03 23:07

    I've faced the same problem, and my internet is currently very slow, so I solved it by changing the gradle in flutter project to an already downloaded one. Just follow these steps:

    1. Go to C:\Users\YOUR_USER_NAME\.gradle\wrapper\dists

    2. You should find one or more folders with the name of the distribution (for example with the name "gradle-4.6-all" if you were developing in Android Studio previously), choose one of these folders (make sure it is not empty) and copy its name.

    3. Open Android Studio project explorer, and locate android\gradle\wrapper\gradle-wrapper.properties

    4. You will find a line like this:
      distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
      Change gradle-5.4.1-all with the folder name you copied in step 2.

    5. Run your app, and hopefully it works this time.

    0 讨论(0)
  • 2021-01-03 23:13

    Goto Android Studio - File - Other Setting - Default Project Structure Uncheck use Embeded JDk Below, set your JDK path. Found in Program files - Java - Jdk.

    0 讨论(0)
  • 2021-01-03 23:15

    Providing an active internet connection worked for me.

    To build gradle offline,

    For Windows,

    Go to File -> Settings.

    And open the 'Build,Execution,Deployment'. Then open the

    Build Tools -> Gradle

    Then check the box -> Offline work below.

    Click the OK button.

    For Mac OS,

    go to Android Studio -> Preferences, and the rest is the same.

    0 讨论(0)
提交回复
热议问题