Flutter: Build an Android app with Gradle

Andres Sandoval
2 min readJan 2, 2021

Gradle is a build system used to build Android apps. Android developers use Android Studio and Gradle to build Android apps. Now with Flutter the future of mobile development, we develop one app (Dart language) and it runs on three platforms(Android, iOS, and Web). We need to learn Flutter and Gradle configuration. Fun fact: as a software engineer you need to learn to use different programming languages, IDE tools, build systems, etc... When building Android apps the thing that changes the most is the UI layer of the app, everyday there is a new library. The build process when building new Android apps does not change often Gradle. In the last 2–3 years, the biggest change I have seen in the Android build process was to publish the App Bundle(.aab) instead of App APK (.apk).

Build Debug APK:

  1. Create a new Flutter project.
  2. To run Gradle tasks on your Flutter project, using VScode open the terminal and enter the below commands:
cd android
./gradlew

Build a debug app:

./gradlew app:assembleDebug
  1. Gradle build command generates the app file app-debug.apk.
  2. Go to directory /build/app/outputs/apk/debug.
  3. Drag and drop file app-debug.apk to Android device, or use Adb command $adb install app-debug.apk.

Clean Android project:

  1. Deletes all build and output directories and files created.
./gradlew app:clean

All the Gradle tasks in the project enter:

./gradlew tasks — all
./gradlew tasks — all | grep app

Conclusion:

Thanks for reading. I started to publish my Flutter notes. Let me know if I’m wrong somewhere. I’m open to your feedback 🙌🏻

  • Andres

References:

https://developer.android.com/studio/build/index.html

--

--