1、AndroidX简介

点击查看Android文档中对androidx的简介

按照官方文档说明 androidx 是对 android.support.xxx 包的整理后产物。由于之前的support包过于混乱,所以,google推出了 androidX。

由于在后续版本中,会逐步放弃对support 的升级和维护,所以,我们必须迁移到 androidX.对此,官方描述如下:

Existing packages, such as the Android Support Library, are being refactored into AndroidX.
Although Support Library versions 27 and lower are still available on Google Maven,
all new development will be included in only AndroidX versions 1.0.0 and higher.

2、迁移步骤

2.1 修改gradle.properties

android.useAndroidX=true
android.enableJetifier=true

其中:

  • android.useAndroidX=true 表示当前项目启用 androidx
  • android.enableJetifier=true 表示将依赖包也迁移到androidx 。如果取值为false,表示不迁移依赖包到androidx,但在使用依赖包中的内容时可能会出现问题,当然了,如果你的项目中没有使用任何三方依赖,那么,此项可以设置为false

2.2 如何迁移

点击查看官方迁移指南

在AndroidStudio 3.2 或更高版本(目前最新正式版为3.2,其他更高版为alpha版)中执行如下操作:

  • Refactor > Migrate to AndroidX

    image

在执行该操作时会提醒我们是否将当前项目打包备份。如果你提前已经做好了备份,可以忽略;如果没有备份,则先备份。

3 迁移后续

3.1 手动修改错误包名

由于 Migrate to AndroidX 执行之后,部分控件的包名/路径名转换的有问题,所以还需要我们手动调整(包括修改xml布局文件和.java/.kt 文件)。

如:ViewPager,RecyclerView 等,这些内容在迁移完成之后,包名是 androidx.core.weight.xxxx,这是一个错误的包名,我们必须手动修改,否则,无法正常编译——点击绿色 Run(运行) 按钮时会详细报出哪里有错误。

此处需要注意,在 AndroidStudio 的 build 选项卡中一次最多只会报 50条错误!! 所以,可能在你修完第一批之后,后面还有N个50。此处要保持一个平静的

Android:你好,androidX!再见,android.support的更多相关文章

  1. [Android Pro] AndroidX重构和映射

    原文地址:https://developer.android.com/topic/libraries/support-library/refactor https://blog.csdn.net/ch ...

  2. [Android Pro] AndroidX了解一下

    cp : https://blog.csdn.net/qq_17766199/article/details/81433706 1.说明 官方原文如下: We hope the division be ...

  3. Android Studio androidx 包冲突解决方法

    如果包冲突了会包如下这样的错: Android dependency 'androidx.core:core' has different version for the compile (1.0.0 ...

  4. Error : should use android:showAsAction when not using support library

    我有一个ListActivity,然后一个menu/options.xml android:showAsAction报错: should use android:showAsAction when n ...

  5. [Android]官网《Testing Support Library》中文翻译

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/5048524.html 翻译自 Android Develope ...

  6. android studio :com.android.support:appcompat-v7:21.+ 报错

    android studio :com.android.support:appcompat-v7:21.+ 报错: 在project——>app——>build.gradle修改: app ...

  7. Android 自己实现 NavigationView [Design Support Library(1)]

    转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/46405409: 本文出自:[张鸿洋的博客] 一.概述 Google I/O 2 ...

  8. 【Android 应用开发】 Android 各种版本简介 ( Support 支持库版本 | Android Studio 版本 | Gradle 版本 | jcenter 库版本 )

    初学者遇到 Android Studio, 导入工程后, 会出现各种奇葩错误, 如果管理好各个插件, gradle, SDK, SDK Tools, 各种官方依赖库 的版本, 会将错误大大的减少; 这 ...

  9. Android : Error inflating class android.support.design.widget.NavigationView

      之前一直没搞定的,今天终于解决了. Android报错: android.view.InflateException: Error inflating class android.support. ...

随机推荐

  1. 最小费用流判负环消圈算法(poj2175)

    Evacuation Plan Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3384   Accepted: 888   ...

  2. php 常用的系统函数

    字符串函数 strlen:获取字符串长度,字节长度 substr_count 某字符串出现的次数 substr:字符串截取,获取字符串(按照字节进行截取) mb_strlenmb_substr str ...

  3. centos7.4yum错误

    1. 首先删除redhat原有的yum   rpm -aq | grep yum | xargs rpm -e --nodeps   rpm -aq | grep python-iniparse | ...

  4. 170525、解决maven隐式依赖包版本问题

    今天在使用dubbo2.5.3版本的时候,启动项目的时候发现一个问题,tomcat启动一直报错 Caused by: java.lang.IllegalStateException: Context ...

  5. Air Raid---hdu1151(最小路径覆盖)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1151 最小路径覆盖 == 顶点数 - 最大匹配. #include<stdio.h> #i ...

  6. Python开发【模块】:sqlalchemy

    一.对象映射关系(ORM) orm英文全称object relational mapping,就是对象映射关系程序,简单来说我们类似python这种面向对象的程序来说一切皆对象,但是我们使用的数据库却 ...

  7. Java压缩多个文件并导出

    controller层: /** * 打包压缩下载文件 */ @RequestMapping(value = "/downLoadZipFile") public void dow ...

  8. Scala的类与类型

    类和类型 List<String>和List<Int>类型是不一样的,但是jvm运行时会采用泛型擦除.导致List<String>和List<Int>都 ...

  9. 中文乱码—Servlet—SpringMVC

    一.SpringMVC中的中文乱码问题 a:处理全局请求的中文乱码(配置Web.xml的字符编码过滤器) <filter> <filter-name>encodingFilte ...

  10. redis—Spring中redis缓存的简单使用

    这里使用的是 Spring-4.3 , redis-2.8 的版本   1.添加maven依赖 <dependency> <groupId>redis.clients</ ...