0

I've been using Flutter for almost a year now, I never used Android Studio or Android application development with Java/Kotlin. Most often I get these errors related to Gradle, changing classpaths and implementation and I don't seem to understand any of that.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Manish
  • 417
  • 5
  • 10
  • 1
    android folder is for android platform that is itself an android project. gradle is configuration file used for android app development. flutter is cross platform so, folder like android and ios also created for respective os platforms – Hardik Mehta Jun 23 '22 at 13:16
  • can you provide any resources where i can actually understand how do they work and where gradle comes in between. It will be of so much help @HardikMehta – Manish Jun 23 '22 at 13:18
  • you can check this link for android project structure : https://www.geeksforgeeks.org/android-project-folder-structure/ and for gradle : https://developer.android.com/studio/build Hope this will help you – Hardik Mehta Jun 23 '22 at 13:20
  • Might be relevant: https://stackoverflow.com/q/16754643/what-is-gradle-in-android-studio – E_net4 Jun 23 '22 at 13:53
  • Understand this as, Flutter is a common way to create apps for Android, iOs, Mac, Linux, Windows and Web. Now, everyone of these types have their own unique way of working and required files in specific format. So, when you create a Flutter project, to run it in Android, you've to output in a form recognizable by Android for which you require the Android folder and gradle to process the output. Same like this, iOs is to get the output of iPhones, same for others, desktop folder for windows, web for web etc. Now, Flutter is already capable to do the respective output as told. – Lalit Fauzdar Jun 23 '22 at 15:42

1 Answers1

1

Any app in the Flutter is created with the help of three languages Dart, C and C++. Here you can also tell that every flutter application is a combination of these three language’s code.

The Entire Flutter framework is created in Dart and it is also used by us to develop an app. Here also notice that we do not directly use C and C++ code to write apps, instead, C and C++ code is used in Graphic rendering engine and Dart Virtual machine to perform their tasks.

Let's dig deeper on how flutter compiles for Android

  • Graphics Engine’s C and C++ code are compiled with the help of Android’s NDK (Native Development Kit).
  • The dart code both SDK’s and ours are compiled through AOT (Ahead-of-Time) compilation process to native ARM and x86 libraries.
  • After successful compilation, the APK file is generated.
  • Any widget rendering, input-output, event handling and so on is done by compiled app code.
  • Here notice that Debug mode builds use a Dart virtual machine to run Dart code in order to enable stateful hot reload.

flutter

So related to the folder structure, ios contains part of iOS code and uses CocoaPods to manage dependencies. The android contains part of Android code and uses Gradle to manage dependencies. The lib contains part of Dart code and uses pub to manage dependencies. Cocoapods in iOS corresponds to Podfile and Podfile.lock while pub corresponds to pubspec.yaml and pubspec.lock.

The iOS/Android project under Flutter is still essentially a standard iOS/Android project. Flutter only generates and embeds App.framework and Flutter.framework (iOS) by adding a shell to the BuildPhase. Flutter also adds flutter.jar and vm/isolate_snapshot_data/instr (Android) through gradle to compile Flutter-related code and embed them into a native App.

If you want more depth information about the compilation process see this article https://www.alibabacloud.com/blog/an-in-depth-understanding-of-flutter-compilation-principles-and-optimizations_597747

Kevin Cando
  • 170
  • 7