Fluent module packaging AAR


Fluent module packaging AAR

Fluent version 1.17 one

Google packaging AAR

flutter build aar

android {
  // ...

repositories {
  maven {
    url 'some/path/my_flutter/build/host/outputs/repo'
    // This is relative to the location of the build.gradle file
    // if using a relative path.
  maven {
    url 'https://storage.googleapis.com/download.flutter.io'

dependencies {
  // ...
  debugImplementation 'com.example.flutter_module:flutter_debug:1.0'
  profileImplementation 'com.example.flutter_module:flutter_profile:1.0'
  releaseImplementation 'com.example.flutter_module:flutter_release:1.0'

The AAR package printed in this way does not include third-party plug-ins into AAR, but relies on the local warehouse, so it is not suitable for joint development

Fat AAR plug-in packaging

Using the fat AAR plug-in, you can combine third-party plug-ins and things related to fluent into one AAR

Integrated fat AAR
  • Add dependencies to the root directory gradle

    dependencies {
        classpath "com.kezong:fat-aar:1.2.15"
  • Configuration under app directory

    //Set to library when packaging
    boolean isAarLibrary = true
    def localProperties = new Properties()
    def localPropertiesFile = rootProject.file('local.properties')
    if (localPropertiesFile.exists()) {
        localPropertiesFile.withReader('UTF-8') { reader ->
    def flutterRoot = localProperties.getProperty('flutter.sdk')
    if (flutterRoot == null) {
        throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
    def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
    if (flutterVersionCode == null) {
        flutterVersionCode = '1'
    def flutterVersionName = localProperties.getProperty('flutter.versionName')
    if (flutterVersionName == null) {
        flutterVersionName = '1.0'
    //New: when AAR needs to be packaged, modify the item to library mode
    if (isAarLibrary) {
        apply plugin: 'com.android.library'
    } else {
        apply plugin: 'com.android.application'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
    //New: import fat AAR
    if (isAarLibrary) {
        apply plugin: 'com.kezong.fat-aar'
    defaultConfig {
            //Note that the library mode does not require an applicationid
            if (!isAarLibrary) {
                applicationId "com.ecook.zuofan_flutter"
            minSdkVersion 16
            targetSdkVersion 28
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName

  • Using fat AAR

    Note: io flutter:flutter_ embedding_ The release version number can be downloaded locally gradle/caches/modules-2/files-2.1/io. Get from the fluent directory

    dependencies {
        if (isAarLibrary) {
                embed "io.flutter:flutter_embedding_release:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32"
            //Add each CPU version of fluent so
    //        embed "io.flutter:arm64_v8a_debug:1.0.0-eed171ff3538aa44f061f3768eec3a5908e8e852"
    //        embed "io.flutter:armeabi_v7a_debug:1.0.0-eed171ff3538aa44f061f3768eec3a5908e8e852"
            embed "io.flutter:arm64_v8a_release:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32"
            embed "io.flutter:armeabi_v7a_release:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32"
            //Add fat AAR to process flutter and package it into three-party dependencies in AAR
            def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
            def plugins = new Properties()
            def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
            if (pluginsFile.exists()) {
                pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
            plugins.each { name, _ ->
                embed project(path: ":$name", configuration: 'default')
  • Modification android/app/AndroidManifest. XML file

    Our project is a fluent project, so when packaged into AAR, we need to comment out useless tags and only keep the application tag

    <manifest xmlns:android = "http://schemas.android.com/apk/res/android"
      package = "com.flutter.flutter_aar_demo"
      //Keep only the application tag
      //This needs to be kept
  • Compile package

    Package and execute under Android directorygradlew assembleRelease

    Wait to get AAR

Recommended Today

Chapter 45 SQL command from (I)

Chapter 45 SQL command from (I) A select clause that specifies one or more tables to query. outline SELECT … FROM [optimize-option] table-ref [[AS] t-alias][,table-ref [[AS] t-alias]][,…] parameter optimize-optioN – optional – specifies a single keyword or a series of keywords separated by spaces for query optimization options (optimizer tips). The following keywords are supported:%ALLINDEX、%FIRSTTABLE […]