Flutter 之 1.12+版本嵌入到原生项目

官方提供的方案

  1. Open /app/build.gradle
  2. Ensure you have the repositories configured, otherwise add them:
      repositories {
        maven {
            url '/Users/walkingMen/android_project/queen/queen_flutter_boost/build/host/outputs/repo'
        }
        maven {
            url 'http://download.flutter.io'
        }
      }
  1. Make the host app depend on the Flutter module:
    dependencies {
      debugImplementation 'com.iksocial.queen_flutter:flutter_debug:1.0
      profileImplementation 'com.iksocial.queen_flutter:flutter_profile:1.0
      releaseImplementation 'com.iksocial.queen_flutter:flutter_release:1.0
    }

  1. Add the profile build type:
    android {
      buildTypes {
        profile {
          initWith debug
        }
      }
    }

aar方案:不依赖本地仓库

step1:
找到flutter根目录下的build/host/outputs/repo,将flutter_release-1.0.aar复制到android项目下
step2:
找到flutter根目录下的build/host/outputs/repo, 将flutter_release-1.0.pom,里面有如下flutter基础库的地址


  io.flutter
  flutter_embedding_release
  1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c
  compile


  io.flutter
  armeabi_v7a_release
  1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c
  compile

step3:
/app/build.gradle下添加

repositories {
        maven {
            url 'http://download.flutter.io'
        }
      }
dependencies {
    implementation(name: 'flutter_release-1.0', ext: 'aar')
    implementation 'io.flutter:flutter_embedding_release:1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c'
    implementation 'io.flutter:armeabi_v7a_release:1.0.0-e1e6ced81d029258d449bdec2ba3cddca9c2ca0c'
    }

aar方案无非就是直接将flutter基础库引入进来。

你可能感兴趣的:(Flutter 之 1.12+版本嵌入到原生项目)