Your Flutter application is created using an older version of the Android embedding
来源:blog.csdn.net 更新时间:2023-05-25 21:55
在打开旧的flutter项目时可能会遇到如下2个警告(FlutterSDK1.22.4创建的新项目不会存在这2个问题,所以用新项目和旧项目对比一下就容易找到修复问题的办法):
警告1、
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2.
解决办法:打开android目录下的app文件夹下的AndroidManifest.xml文件,在activity标签的下面增加如下代码:
<meta-data
android:name="flutterEmbedding"
android:value="2" />
然后一运行项目出现如下报错:
error: incompatible types: MainActivity cannot be converted to FlutterEngine
GeneratedPluginRegistrant.registerWith(this)
解决办法:注释掉这行代码就ok
警告2、
[!] Your app isn't using AndroidX.
To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
解决办法:在android文件夹的gradle.properties中添加如下代码即可:
android.enableJetifier=true
android.useAndroidX=true