zoukankan      html  css  js  c++  java
  • Migrate to AndroidX 遇到的坑

    Androidx 迁移方法:

    首先把 gradle 版本改为3.2.0以上,以及 compileSdkVersion 为28以上

    然后 Android Studio 菜单栏 Refactor -> Migrate to AndroidX

    如果是新项目,使用AndroidX相关依赖,可以在gradle.properties文件里添加配置:

    android.useAndroidX=true
    android.enableJetifier=true
    

    如果你只是想使用AndroidX,但是之前的不迁移,可以这样配置:

    android.useAndroidX=true
    android.enableJetifier=false

    迁移完成后运行报错。。。

    Conflict with dependency 'androidx.lifecycle:lifecycle-runtime' in project ':app'. Resolved versions for runtime classpath (2.0.0-rc01) and compile classpath (2.0.0) differ. This can lead to runtime crashes. To resolve this issue follow advice at https://developer.android.com/studio/build/gradle-tips#configure-project-wide-properties. Alternatively, you can try to fix the problem by adding this snippet to ..........uild.gradle:
    ​

    根据提示解决:

    subprojects {
        project.buildDir = "${rootProject.buildDir}/${project.name}"
    
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "27.1.1"
                }else if(details.requested.group == 'androidx.lifecycle')
                {
                    details.useVersion "2.0.0-rc01"
                }else if(details.requested.group == 'androidx.versionedparcelable')
                {
                    details.useVersion "1.0.0-rc01"
                }else if(details.requested.group == 'androidx.core')
                {
                    details.useVersion "1.0.0-rc01"
                }
            }
        }
    }
    

      

  • 相关阅读:
    Android -- DiskLruCache
    Android -- EventBus解析
    Android -- Annotation
    Ubuntu 1604 安装配置 kafka,并配置开机自启(systemctl)
    zookeeper/kafka的部署
    pdf 中内容的坐标系
    C# 获取Windows 设备信息
    C#读取Word指定页的内容
    再看C# ThreadPool与Task的认识总结
    同步IO、异步IO、阻塞IO、非阻塞IO之间的联系与区别
  • 原文地址:https://www.cnblogs.com/crane13/p/10959803.html
Copyright © 2011-2022 走看看