zoukankan      html  css  js  c++  java
  • Flutter兼容AndroidX

    参考官方文档:https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

    第一步

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

      如下图:

    第二步

    android/build.gradle,修改:

    classpath 'com.android.tools.build:gradle:3.3.0'

    第三步

    android/gradle.properties中添加:

    android.enableJetifier=true
    android.useAndroidX=true

    第四步

    android/app/build.gradle中的android下面确保compileSdkVersion 和 targetSdkVersion 最少是 28.

    如下图:

    第五步

    将所有support都替换成androidx,
    比如将:

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    替换

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    再将:

    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.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    如图

    6 回避 AndroidX:

    如果不想配置AndroidX,在使用依赖库的时候,就要选择该依赖库没有迁移到AndroidX的最后版本,主要的依赖库如下:

    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
  • 相关阅读:
    leetcode-19-merge
    leetcode-18-remove
    R-codes-tips
    python-bioInfo-codes-2
    Java-framework-Vaadin
    leetcode-17-BST
    生物信息学-知识笔记-1
    leetcode-16-greedyAlgorithm
    perl-tips-1
    计算机网络HTTP、TCP/IP包
  • 原文地址:https://www.cnblogs.com/xiaochii/p/12206473.html
Copyright © 2011-2022 走看看