Skip to content

Commit 7f7690e

Browse files
reidbakersfshaza2
andauthored
Document how to determine if an app is a flutter app (#12668)
_Description of what this PR is changing or adding, and why:_ Documents how to tell from a built apk if the app uses flutter. Internal documentation authored by me can be seen by googlers in [go/flutter-android-detection](http://goto.google.com/flutter-android-detection) _Issues fixed by this PR (if any):_ flutter/flutter/issues/170523 _PRs or commits this PR depends on (if any):_ n/a ## Presubmit checklist - [x] If you are unwilling, or unable, to sign the CLA, even for a _tiny_, one-word PR, please file an issue instead of a PR. - [ ] If this PR is not meant to land until a future stable release, mark it as draft with an explanation. - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style)—for example, it doesn't use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first-person pronouns). - [ ] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Shams Zakhour <[email protected]>
1 parent 803b526 commit 7f7690e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/content/deployment/android.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,50 @@ panel (debug is the default):
636636
The resulting app bundle or APK files are located in
637637
`build/app/outputs` within your app's folder.
638638

639+
### How to tell if an apk uses Flutter?
640+
641+
Recommended: Using APK files
642+
[apkanalyzer](https://developer.android.com/tools/apkanalyzer) files list --files-only <SOME-APK>
643+
Then looking for a file in `/lib/<ARCH>/libflutter.so`
644+
645+
Example:
646+
`apkanalyzer files list some-flutter-app.apk | grep flutter.so | wc -l`
647+
returns any number greater than 0.
648+
649+
**Why this works**
650+
Flutter depends on C++ code used by the Flutter engine. In Android,
651+
this code is bundled with the Flutter framework and the developer's
652+
Dart code as a native library called `libflutter.so`.
653+
The Java/Android tooling renames the `flutter` library with the `lib` prefix
654+
and handles library location across architectures.
655+
This is how some reverse engineer an APK to identify it as a Flutter app.
656+
657+
#### Secondary Evaluation:
658+
Run `apkanalyzer manifest print <SOME-APK>` and look for a `<meta-data>` tag with `android:name="flutterEmbedding"`.
659+
The value can be `1` or `2`.
660+
661+
Example:
662+
`apkanalyzer manifest print some-flutter-app.apk | grep flutterEmbedding -C 2`
663+
returns the following style string.
664+
```
665+
<meta-data
666+
android:name="flutterEmbedding"
667+
android:value="2" />
668+
```
669+
670+
671+
**Why this works**
672+
Flutter has had two different embedders, and this flag was read to determine which embedder was used.
673+
Flutter 3.22 removed the ability of v1 embedder apps to build.
674+
https://blog.flutter.dev/whats-new-in-flutter-3-22-fbde6c164fe3
675+
This mechanism is not recommended because it is unclear how long the `flutterEmbedding` value will
676+
continue to be included in all Flutter apps. Additionally, this will not work for all libraries written
677+
in Flutter that are imported into Android apps as AAR dependencies.
678+
679+
#### Non-technical evaluation
680+
* Download [Flutter Shark](https://play.google.com/store/apps/details?id=com.fluttershark.fluttersharkapp&pli=1) on a device and let it scan local apps.
681+
* Visit the [Flutter Hunt](https://flutterhunt.com/) website.
682+
639683
{% comment %}
640684
### Are there any special considerations with add-to-app?
641685
{% endcomment %}

0 commit comments

Comments
 (0)