适配AndroidX时build apk提示错误

flutter build apk提示2个错误

Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.2) classpath. You should manually set the same version via DependencyResolution

androidx.lifecycle不存在

image.png

解决办法:
修改android/build.gradle
将com.android.tools.build:gradle从3.2.1修改为最新版本3.3.2

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
}
image.png
flutter clean
flutter build apk
image.png

完成