准备工作
1.创建native工程
app->build.gradle
android {
//...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
2.创建flutter工程
cd some/path/
flutter create -t module --org com.example my_flutter
1.引入
1.1源码引入
app->settings.gradle
setBinding(new Binding([gradle: this])) // new
evaluate(new File( // new
settingsDir.parentFile, // new
'my_flutter/.android/include_flutter.groovy' // new
))
app
dependencies {
implementation project(':flutter')
}
1.2aar引入
>build aar
cd some/path/my_flutter
flutter build aar
![image.png](https://upload-images.jianshu.io/upload_images/5451204-adf22a7344a4cc5d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
>app->build.gradle
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'
}
##3.体积分析
![image.png](https://upload-images.jianshu.io/upload_images/5451204-afbebdcdee2919f5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)