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

  • Find the JRE path. It is usually in the same directory where you have the Android SDK installed.
  • After copying that path, open Environment Variables by typing env in your search bar and click on Environment variables.

 

We will add a new system variable.

 

  • After this, click on the “New” button under the system variables section, and a prompt will open up. Then, name it JAVA_HOME and paste the copied JRE path in the variable value.

 

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.

 

 

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

Similar Reads

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....

Running Gradle Build in Flutter through the Manual Method

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