tree: 2ad2bd4530631993fb126b7ed562916c8cd9ffa8 [path history] [tgz]
  1. context/
  2. external_view_embedder/
  3. io/
  4. jni/
  5. platform_view_android_delegate/
  6. surface/
  7. test/
  8. test_runner/
  9. .gitignore
  10. android_choreographer.cc
  11. android_choreographer.h
  12. android_context_gl_impeller.cc
  13. android_context_gl_impeller.h
  14. android_context_gl_impeller_unittests.cc
  15. android_context_gl_skia.cc
  16. android_context_gl_skia.h
  17. android_context_gl_unittests.cc
  18. android_context_vulkan_impeller.cc
  19. android_context_vulkan_impeller.h
  20. android_display.cc
  21. android_display.h
  22. android_egl_surface.cc
  23. android_egl_surface.h
  24. android_environment_gl.cc
  25. android_environment_gl.h
  26. android_exports.lst
  27. android_image_generator.cc
  28. android_image_generator.h
  29. android_shell_holder.cc
  30. android_shell_holder.h
  31. android_shell_holder_unittests.cc
  32. android_surface_gl_impeller.cc
  33. android_surface_gl_impeller.h
  34. android_surface_gl_skia.cc
  35. android_surface_gl_skia.h
  36. android_surface_software.cc
  37. android_surface_software.h
  38. android_surface_vulkan_impeller.cc
  39. android_surface_vulkan_impeller.h
  40. AndroidManifest.xml
  41. apk_asset_provider.cc
  42. apk_asset_provider.h
  43. apk_asset_provider_unittests.cc
  44. BUILD.gn
  45. build.gradle
  46. flutter_main.cc
  47. flutter_main.h
  48. flutter_shell_native_unittests.cc
  49. gradle.properties
  50. image_external_texture.cc
  51. image_external_texture.h
  52. image_external_texture_gl.cc
  53. image_external_texture_gl.h
  54. image_external_texture_vk.cc
  55. image_external_texture_vk.h
  56. library_loader.cc
  57. ndk_helpers.cc
  58. ndk_helpers.h
  59. platform_message_handler_android.cc
  60. platform_message_handler_android.h
  61. platform_message_response_android.cc
  62. platform_message_response_android.h
  63. platform_view_android.cc
  64. platform_view_android.h
  65. platform_view_android_jni_impl.cc
  66. platform_view_android_jni_impl.h
  67. platform_view_android_unittests.cc
  68. README.md
  69. surface_texture_external_texture.cc
  70. surface_texture_external_texture.h
  71. surface_texture_external_texture_gl.cc
  72. surface_texture_external_texture_gl.h
  73. vsync_waiter_android.cc
  74. vsync_waiter_android.h
shell/platform/android/README.md

Android Platform Embedder

Android embedder for Flutter, including Java io.flutter sources and Android specific engine-side C++.

This code provides the glue between the Flutter engine and the Android platform, and is responsible for:

  • Initializing the Flutter engine.
  • Providing a platform view for the Flutter engine to render into.
  • Dispatching events to the Flutter engine.

[!CAUTION] This is a best effort attempt to document the Android embedder. It is not guaranteed to be up to date or complete. If you find a discrepancy, please send a pull request!

See also:

Developing

How to edit and contribute to the Android embedder.

![TIP] This guide assumes you already have a working Engine development environment:

You should also have a working Android development environment:

It is also recommended (but not required) to install Visual Studio Code.

Depending on what you are trying to do, you may need to edit the Java code in io.flutter or the C++ code in shell/platform/android, sometimes both. Let's start with the C++ code, as it is more similar to developing for other platforms or platform-agnostic parts of the engine.

Editing C++ code

The C++ code for the Android embedder is located in shell/platform/android and subdirectories.

Some notable files include:

See VSCode with C/C++ Intellisense for how to use the clangd extension to get C++ code completion:

Example

![NOTE] > --compile-commands-dir must point to an Android build output:

{
  /* ... */
  "clangd.path": "buildtools/mac-arm64/clang/bin/clangd",
  "clangd.arguments": ["--compile-commands-dir=out/android_debug_unopt_arm64"]
  /* ... */
}

... but remember to change it back when editing other parts of the engine.

Editing Java code

The Java code for the Android embedder is located in io/flutter/ and subdirectories.

The tests are located in test/io/flutter/, and the test runner in test_runner.

Some notable files include:

It is non-trivial to get a working IDE setup for editing Java code in the Flutter engine. Some developers have had success using VSCode as an IDE for the Android Embedding, but the following instructions are for if that doesn't work, or you want to use Android Studio:

  1. Open shell/platform/android in Android Studio.

  2. Configure the following:

  3. Sync Gradle.

    Example

At this point you should be able to open Java files in Android Studio and get code completion in the io/flutter folder (additional, undocumented work is required for test/io/flutter). For example, FlutterJNI.java:

Example