flutter APP 编译运行时报 package androidx && AAPT 、AAPT2 && parsing resources

Android compileSdkVersion 大于等于28时,之前所有的android.support packages全部由androidx代替,如果flutter app 编译输出类似下面的日志

This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX.

毫不怀疑的是:包引入的版本冲突问题。

解决方法一:
把当前工程合并为AndroidX

  1. In android/gradle/wrapper/gradle-wrapper.properties change the line starting with distributionUrl like this

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

  1. In android/build.gradle, replace:
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
}
  1. In android/gradle.properties, append
android.enableJetifier=true
android.useAndroidX=true
  1. In android/app/build.gradle:
make sure compileSdkVersion and targetSdkVersion are at least 28.
  1. android/app/build.gradle中的dependencies里,用androidx代替android.support
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

转换为:

 androidTestImplementation 'androidx.test:runner:1.0.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

解决方法二:
避开AndroidX
之所以不能正常运行,其实也是因为你在pubspec.yaml引入过高版本的依赖。下面给出一些常用在版本28之下的dart package

  • android_alarm_manager: 0.2.3
  • android_intent: 0.2.1
  • battery: 0.3.0
  • camera: 0.2.9+1
  • cloud_firestore: 0.8.2+3
  • cloud_functions: 0.0.5
  • connectivity: 0.3.2
  • device_info: 0.3.0
  • firebase_admob: 0.7.0
  • firebase_analytics: 1.1.0
  • firebase_auth: 0.7.0
  • firebase_core: 0.2.5+1
  • firebase_database: 1.0.5
  • firebase_dynamic_links: 0.1.1
  • firebase_messaging: 2.1.0
  • firebase_ml_vision: 0.2.1
  • firebase_performance: 0.0.8+1
  • firebase_remote_config: 0.0.6+1
  • firebase_storage: 1.0.4
  • google_maps_flutter: 0.1.0
  • google_sign_in: 3.2.4
  • image_picker: 0.4.12+1
  • local_auth: 0.3.1
  • package_info: 0.3.2+1
  • path_provider: 0.4.1
  • quick_actions: 0.2.2
  • sensors: 0.3.5
  • share: 0.5.3
  • shared_preferences: 0.4.3
  • url_launcher: 4.1.0+1
  • video_player: 0.9.0
  • webview_flutter: 0.2.0
    有兴趣的话,可以看看官方介绍https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

你可能感兴趣的:(flutter)