Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. Therefore, i want to run "gradlew build" or similar manually with stacktrace option to see what is happening under the hood. What is the command for that ?

like image 941
Suresh Kumar Avatar asked Jan 01 '23 12:01

Suresh Kumar


1 Answers

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.

like image 67
danypata Avatar answered Jan 04 '23 15:01

danypata