text
stringlengths
1
372
building ahead-of-time (aot) compiled libraries
for x86_64, armeabi-v7a, and arm64-v8a.
consider using the abiFilters android gradle
plugin API to limit the supported architectures in your APK.
doing this avoids a missing libflutter.so runtime crash,
for example:
<code_start>
android {
//...
defaultConfig {
ndk {
// filter for architectures supported by flutter.
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
}
}
}
<code_end>
the flutter engine has an x86 and x86_64 version.
when using an emulator in debug Just-In-Time (jit) mode,
the flutter module still runs correctly.
<topic_end>
<topic_start>
integrate your flutter module
<topic_end>
<topic_start>
integrate with android studio
the android studio IDE can help integrate your flutter module.
using android studio, you can edit both your android and flutter code
in the same IDE.
you can also use IntelliJ flutter plugin functionality like
dart code completion, hot reload, and widget inspector.
android studio supports add-to-app flows on android studio 2022.2 or later
with the flutter plugin for IntelliJ.
to build your app, the android studio plugin configures your
android project to add your flutter module as a dependency.
open your android project in android studio.
go to file > new > new project….
the new project dialog displays.
click flutter.
if asked to provide your flutter SDK path, do so and click next.
complete the configuration of your flutter module.
if you have an existing project:
if you need to create a new flutter project:
click finish.
lightbulb tip
by default, your project’s project pane might show the ‘android’ view.
if you can’t see your new flutter files in the project pane,
set your project pane to display project files.
this shows all files without filtering.
<topic_end>
<topic_start>
integrate without android studio
to integrate a flutter module with an existing android app
manually, without using flutter’s android studio plugin,
follow these steps:
<topic_end>
<topic_start>
create a flutter module
let’s assume that you have an existing android app at
some/path/MyApp, and that you want your flutter
project as a sibling:
this creates a some/path/flutter_module/ flutter module project
with some dart code to get you started and an .android/
hidden subfolder. the .android folder contains an
android project that can both help you run a barebones
standalone version of your flutter module via flutter run
and it’s also a wrapper that helps bootstrap the flutter
module an embeddable android library.
info note
add custom android code to your own existing
application’s project or a plugin,
not to the module in .android/.
changes made in your module’s .android/
directory won’t appear in your existing android
project using the module.
do not source control the .android/ directory
since it’s autogenerated. before building the
module on a new machine, run flutter pub get
in the flutter_module directory first to regenerate
the .android/ directory before building the
android project using the flutter module.
info note
to avoid dex merging issues, flutter.androidPackage should
not be identical to your host app’s package name.
<topic_end>
<topic_start>
java version requirement
flutter requires your project to declare compatibility with java 11 or later.
before attempting to connect your flutter module project
to your host android app, ensure that your host android
app declares the following source compatibility within your
app’s build.gradle file, under the android { } block.
<code_start>
android {
//...
compileOptions {
sourceCompatibility 11 // the minimum value
targetCompatibility 11 // the minimum value
}
}