Skip to content Skip to sidebar Skip to footer

How To Run Gradle Build Manually On A Flutter Project

Currently, I am getting 'Finished with error: Gradle task assembleDebug failed with exit code 1' while trying to build a Flutter project (flutter run). The logs do not help much. T

Solution 1:

For posterity I will post my comment as an answer too and I'll elaborate it a bit.

When you create a flutter project there are two new folders created inside the main folder, one is android and one is ios.

The android folder contains the Android native code and all the android configurations, you can handle it as a native android project.

The ios folder contains the iOS native code and all the ios configurations, it also has the xcworkspace file which can be opened with Xcode like a normal ios project.

Now you can run platform specific commands in each folder, like i said, the folders contain actual native projects.

So for Android you could do:

    cd android/
    ./gradlew clean
    ./gradlew build

(clean and build the project)

For iOS you could do:

   cd ios/
   pod repo update
   pod install

(update the pod repo and install the pods)

Just a short reminder, if you want to create apk/ipa from the native folders, don't forget to run flutter build in the main folder, otherwise you might get outdated code in your apk/ipa.


Solution 2:

  1. Go to the folder where you have gradle installed(the place where your GRADLE_HOME variable points to). Folder where my gradle is installed

  2. Move inside the wrapper folder Pointing an arrow towards the gradle wrapper folder

  3. Move inside the dists folder which is inside the wrapper folder Gradle dists folder inside the wrapper folder

  4. Delete everything that you can find inside the dists folder(cached gradle wrapper) Content of gradle dists folder

  5. Run/launch your android flutter project again. It should re-download the gradle wrapper and if you don't have any connection problems your project should run correctly.

Note: I'm having the same problem because of my unstable internet connection. I'm ending up with a corrupted gradle wrapper file and the download doesn't restart.

  1. If the download gets interrupted and fails to completely download and launch your project repeat all of the steps.

Post a Comment for "How To Run Gradle Build Manually On A Flutter Project"