Flutter与Android的原生混合开发学习中遇到一些问题,现在记录如下。
首先看一下如何创建一个Flutter module.
在Android原生项目的同级目录使用如下命令创建一个flutter_module
flutter create -t module flutter_module
之后会有如下的输出:
➜ ~ flutter create -t module flutter_module
╔════════════════════════════════════════════════════════════════════════════╗
║ A new version of Flutter is available! ║
║ ║
║ To update to the latest version, run "flutter upgrade". ║
╚════════════════════════════════════════════════════════════════════════════╝
Creating project flutter_module... androidx: true
flutter_module/test/widget_test.dart (created)
flutter_module/flutter_module.iml (created)
flutter_module/.gitignore (created)
flutter_module/.metadata (created)
flutter_module/pubspec.yaml (created)
flutter_module/README.md (created)
flutter_module/lib/main.dart (created)
flutter_module/flutter_module_android.iml (created)
flutter_module/.idea/libraries/Flutter_for_Android.xml (created)
flutter_module/.idea/libraries/Dart_SDK.xml (created)
flutter_module/.idea/modules.xml (created)
flutter_module/.idea/workspace.xml (created)
Running "flutter pub get" in flutter_module... 4.9s
Wrote 12 files.
All done!
Your module code is in flutter_module/lib/main.dart.
如上就表示创建成功了。
报错:Error:com.android.builder.dexing.DexArchiveBuilderException
在项目的app/build.gradle文件的android节点下添加如下代码
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
网友评论