Open In App

How to Run Gradle Build in Flutter?

Gradle is a tool that is used to automate tasks in android development. The Gradle build is one specific task that can be used to create APK files for your app. Often, the flutter run/build tasks don’t work as desired, and in those cases, cleaning and building the Gradle again can be helpful. There are two methods to achieve this,

  1. Through command line
  2. Through manual method

Running Gradle Build in Flutter through Command Line

Open the terminal at the root of your flutter project. Then we’ll need to cd into the android directory and run the command. You need to have JDK and JRE installed to run this. 



Note: If you get a path error, navigate and find your JRE, copy the 

 

Path, and open Environment Variables, then add it to the system path. Follow the steps given below



 

We will add a new system variable.

 

 

After this, run the following commands from the root of your flutter app project.

cd android

./gradlew clean build

This will run the Gradle build process for you. You might see a few warnings, but they’re fine as long as there’s no error.

 

 

Running Gradle Build in Flutter through the Manual Method

You can also download the latest Gradle and replace it in the Gradle source location,

 

That’s it. Now you can run the flutter run or build command with the new Gradle version. So that’s how we can run Gradle build in flutter and debug our apps.

Article Tags :