报错内容
flutter Error “Android dependency 'androidx.core:core' has
different version” using flutter_local_notifications and location
packages](https://stackoverflow.com/questions/54823084/flutter-
error-android-dependency-androidx-corecore-has-different-version-us)
问题描述
Android code often uses the [`android.support`](https://developer.android.com/topic/libraries/support-library/) libraries to ensure backwards compatibility. The `android.support` libraries are deprecated, and replaced with [AndroidX](https://developer.android.com/jetpack/androidx/). AndroidX has feature parity with the old libraries with some additional capabilities but, unfortunately, these two sets of libraries are incompatible.
*Gradle crashes when trying to build an APK that relies on both sets of libraries.* This page explains how you can workaround this issue.
## [](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility#fixing-androidx-crashes-in-a-flutter-app)
大致意思是说官方把android支持库升级成androidx,两者不兼容
解决办法
1.flutter 插件最新版本(主要是最新版的一般是值支持andoridX)
- 设置支持andoridX
具体步骤如下:
在 android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip
在 android/build.gradle
dependencies { classpath 'com.android.tools.build:gradle:3.3.0' }
其中的 buildscript { (if it includes kotlin)
ext.kotlin_version = '1.3.0'
在 android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
在 android/app/build.gradle:
compileSdkVersion 28 #至少28
targetSdkVersion 28 #至少28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
下面的 dependencies 中
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
其中 defaultConfig 添加
multiDexEnabled true