什么是安卓X? [英] What is AndroidX?
问题描述
我正在阅读有关 Android 房间库的信息.我看到他们将包 android
更改为 androidx
.我不明白.有人能解释一下吗?
实现androidx.room:room-runtime:$room_version"annotationProcessor "androidx.room:room-compiler:$room_version"
即使这也适用于 android
包.
实现android.arch.persistence.room:runtime:$room_version"annotationProcessor "android.arch.persistence.room:compiler:$room_version"
- 需要在
androidx
而不是android
中打包新的支持库? - 现有项目中的用例和影响因素.
AndroidX - Android 扩展库
来自
<块引用>新项目
把这些标志放在你的 gradle.properties
android.enableJetifier=trueandroid.useAndroidX=真
什么是Jetifier?
迁移错误
- 如果您构建应用程序,并在迁移后发现一些错误,那么您需要修复这些小错误.您不会卡在那里,因为这很容易解决.
- 第三方库不会在目录中转换为 AndroidX,但它们会在运行时通过 Jetifier,所以不用担心编译时错误,你的应用会完美运行.
支持 28.0.0 是最后一个版本吗?
<块引用>这将是 android.support 下的最后一个功能发布打包,鼓励开发者迁移到 AndroidX 1.0.0
那就用AndroidX吧,因为Android从现在开始只会更新androidx包.
进一步阅读
https://developer.android.com/topic/libraries/support-library/androidx-overview
https://android-developers.googleblog.com/2018/05/hello-world-androidx.html
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"
Even this is available with the android
package also.
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
- What was in need of packaging new support libraries in
androidx
instead ofandroid
? - Use case and affect factors in existing projects.
AndroidX - Android Extension Library
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.
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
Complete Artifact mappings for AndroidX packages
AndroidX uses Semantic-version
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.
How to migrate current project
In Android Studio 3.2 (September 2018), there is a direct option to migrate existing project to AndroidX
. This refactor all packages automatically.
Before you migrate, it is strongly recommended to backup your project.
Existing project
- Android Studio > Refactor Menu > Migrate to AndroidX...
- It will analyze and will open Refractor window in bottom. Accept changes to be done.
New project
Put these flags in your gradle.properties
android.enableJetifier=true
android.useAndroidX=true
Check @Library mappings for equal AndroidX package.
Check @Official page of Migrate to AndroidX
What is Jetifier?
Bugs of migrating
- 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.
Support 28.0.0 is last release?
From Android Support Revision 28.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
So go with AndroidX, because Android will update only androidx package from now.
Further Reading
https://developer.android.com/topic/libraries/support-library/androidx-overview
https://android-developers.googleblog.com/2018/05/hello-world-androidx.html
这篇关于什么是安卓X?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!