text
stringlengths 1
474
|
|---|
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
|
}
|
}<code_end>
|
<topic_end>
|
<topic_start>Centralize repository settings
|
Starting with Gradle 7, Android recommends using centralized repository
|
declarations in settings.gradle instead of project or module level
|
declarations in build.gradle files.Before attempting to connect your Flutter module project to your
|
host Android app, make the following changes.Remove the repositories block in all of your app’s build.gradle files.Add the dependencyResolutionManagement displayed in this step to the
|
settings.gradle file.<topic_end>
|
<topic_start>
|
Add the Flutter module as a dependency
|
Add the Flutter module as a dependency of your
|
existing app in Gradle. You can achieve this in two ways.Android archive
|
The AAR mechanism creates generic Android AARs as
|
intermediaries that packages your Flutter module.
|
This is good when your downstream app builders don’t
|
want to have the Flutter SDK installed. But,
|
it adds one more build step if you build frequently.Module source code
|
The source code subproject mechanism is a convenient
|
one-click build process, but requires the Flutter SDK.
|
This is the mechanism used by the Android Studio IDE plugin.<topic_end>
|
<topic_start>Depend on the Android Archive (AAR)
|
This option packages your Flutter library as a generic local
|
Maven repository composed of AARs and POMs artifacts.
|
This option allows your team to build the host app without
|
installing the Flutter SDK. You can then distribute the
|
artifacts from a local or remote repository.Let’s assume you built a Flutter module at
|
some/path/flutter_module, and then run:Then, follow the on-screen instructions to integrate.More specifically, this command creates
|
(by default all debug/profile/release modes)
|
a local repository, with the following files:To depend on the AAR, the host app must be able
|
to find these files.To do that, edit settings.gradle in your host app
|
so that it includes the local repository and the dependency:</br><topic_end>
|
<topic_start>
|
Kotlin DSL based Android Project
|
After an aar build of a Kotlin DSL-based Android project,
|
follow these steps to add the flutter_module.Include the flutter module as a dependency in
|
the Android project’s app/build.gradle file.
|
<code_start>android {
|
buildTypes {
|
release {
|
...
|
}
|
debug {
|
...
|
}
|
create("profile") {
|
initWith(getByName("debug"))
|
}
|
}
|
dependencies {
|
// ...
|
debugImplementation "com.example.flutter_module:flutter_debug:1.0"
|
releaseImplementation 'com.example.flutter_module:flutter_release:1.0'
|
add("profileImplementation", "com.example.flutter_module:flutter_profile:1.0")
|
}<code_end>
|
The profileImplementation ID is a custom configuration to be
|
implemented in the app/build.gradle file of a host project.
|
<code_start>configurations {
|
getByName("profileImplementation") {
|
}
|
}<code_end>
|
<code_start>include(":app")
|
dependencyResolutionManagement {
|
repositories {
|
maven(url = "https://storage.googleapis.com/download.flutter.io")
|
maven(url = "some/path/flutter_module_project/build/host/outputs/repo")
|
}
|
}<code_end>
|
error Important
|
If you’re located in China, use a mirror site rather than the
|
storage.googleapis.com domain. To learn more about mirror sites,
|
check out Using Flutter in China page.lightbulb Tip
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.