什么是AndroidX? [英] What is AndroidX?
问题描述
我正在阅读有关Android房间库的信息.我看到他们将包android
更改为androidx
.我不明白.有人可以解释吗?
I am reading about a room library of Android. I see they changed package android
to androidx
. I did not understand that. Can someone explain, please?
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
即使android
包也提供此功能.
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
- 什么需要在
androidx
中而不是在androidx
中打包新的支持库? - 现有项目中的用例和影响因素.
- What was in need of packaging new support libraries in
androidx
instead ofandroid
? - Use case and affect factors in existing projects.
- Android Studio>重构菜单>迁移到AndroidX ...
- 它将进行分析并在底部打开折射器"窗口.接受要完成的更改.
推荐答案
AndroidX-Android扩展库
来自 AndroidX文档
我们正在推出一种新的包装结构,以使其更清晰地显示 软件包与Android操作系统捆绑在一起,并且 与您的应用的APK打包在一起.展望未来,android.*包 层次结构将保留给随 操作系统.其他软件包将在新的androidx中发布.* 包层次结构作为AndroidX库的一部分.
We are rolling out a new package structure to make it clearer which packages are bundled with the Android operating system, and which are packaged with your app's APK. Going forward, the android.* package hierarchy will be reserved for Android packages that ship with the operating system. Other packages will be issued in the new androidx.* package hierarchy as part of the AndroidX library.
需要AndroidX
AndroidX是经过重新设计的库,用于使程序包名称更清晰.因此,从现在开始, android 层次结构将仅适用于android操作系统附带的android默认类,而其他库/依赖项将成为 androidx 的一部分(更合理).因此,从现在开始,所有新开发都将在androidx中进行更新.
Need of AndroidX
AndroidX is a redesigned library to make package names more clear. So from now on android hierarchy will be for only android default classes, which comes with android operating system and other library/dependencies will be part of androidx (makes more sense). So from now on all the new development will be updated in androidx.
com.android.support.**: androidx.
com.android.support:appcompat-v7: androidx.appcompat:appcompat
com.android.support:recyclerview-v7: androidx.recyclerview:recyclerview
com.android.support:design: com.google.android.material:material
com.android.support.** : androidx.
com.android.support:appcompat-v7 : androidx.appcompat:appcompat
com.android.support:recyclerview-v7 : androidx.recyclerview:recyclerview
com.android.support:design : com.google.android.material:material
Complete Artifact mappings for AndroidX packages
以前,support library
使用的是SDK版本,而AndroidX使用 Semantic-version
.它将从28.0.0→1.0.0转换为版本.
Previously, support library
used the SDK version but AndroidX uses the Semantic-version
. It’s going to re-version from 28.0.0 → 1.0.0.
在Android Studio 3.2(2018年9月)中,有直接选项可以将现有项目迁移到AndroidX
.这将自动重构所有软件包.
In Android Studio 3.2 (September 2018), there is a direct option to migrate existing project to AndroidX
. This refactor all packages automatically.
在迁移之前,强烈建议您备份项目.
现有项目
新项目
将这些标志放在您的gradle.properties
android.enableJetifier=true
android.useAndroidX=true
检查@ 相等的AndroidX软件包的库映射.
检查@ 迁移到AndroidX的官方页面
- If you build app, and find some errors after migrating, then you need to fix those minor errors. You will not get stuck there, because that can be easily fixed.
- 3rd party libraries are not converted to AndroidX in directory, but they get converted at run time by Jetifier, so don't worry about compile time errors, your app will run perfectly.
这将是android.support下的最后一个功能版本 包装,并鼓励开发人员迁移到AndroidX 1.0.0
This will be the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX 1.0.0
请使用AndroidX,因为Android从现在开始仅更新androidx软件包.
So go with AndroidX, because Android will update only androidx package from now.
https://developer.android.com/topic/libraries/support-library/androidx-overview
https://android-developers.googleblog.com/2018/05/hello-world-androidx.html
这篇关于什么是AndroidX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!