Android: AndroidX back compatibility - android

I want to use AndroidX library, but in the official Google developer website, they said it works with Android 9 and SDK 28, and I’m using Android 6 with SDK 23, can I use AndroidX in my project? Or should I continue to use support library ? I found no information on the Internet.
Thanks.

Yes, you can use AndroidX and you should use it. It provides complete back compatibility just as support library does.Actually it is nothing but a major improvement to support library. Android have introduced it in Jetpack and from now on, the new features to support library would be introduced in AndroidX. So you should use it.
Keep in mind, you have to set it up in gradle.properties file as mentioned in the android documentation. https://developer.android.com/jetpack/androidx

Related

Use legacy support library option in android

Should I select the Use legacy android.support libraries option when creating a new project? What will happen if I don't select this option?
A little context:
Up until recently, almost every Android app used the android.support libraries so that they could use features introduced on new Android versions also on older Android versions. You can read about it here: https://developer.android.com/topic/libraries/support-library
Recently, Google announced that there would be no new releases for the support library, and that instead the support library would become a new library called AndroidX. Here's their announcement:
With the release of Android 9.0 (API level 28) there is a new version
of the support library called AndroidX which is part of Jetpack. The
AndroidX library contains the existing support library and also
includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts
(those versioned 27 and earlier, and packaged as android.support.*)
will remain available on Google Maven. However, all new library
development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well.
So all Android apps should now aim to use AndroidX, instead of the old support library. When you create a new project in Android Studio, it will by default use AndroidX, but you can still choose to Use legacy android.support libraries if you wish, by clicking the checkbox you found.
Most of the time, you probably want to use AndroidX
With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components.
Support Library
If you check this option, the android studio will use android.support library otherwise it will use androidx library.
the android.support library is deprecated, so you don't need to check this option.
The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later.
Check the artifact-mappings and also check support-library
When developing apps that support multiple API versions, you may want a standard way to provide newer features on earlier versions of Android or gracefully fall back to equivalent functionality. Rather than building code to handle earlier versions of the platform, you can leverage these libraries to provide that compatibility layer. In addition, the Support Libraries provide additional convenience classes and features not available in the standard Framework API for easier development and support across more devices.

Any issue if a library I shipped uses AndroidX but the app using it is not?

I have developed an Android Library which is still using old support libraries. Recently one of my user facing multiple issues while integrating it with their App since they are using AndroidX libraries.
I am wondering whether I should migrate to AndroidX? If so, will there be any compatibility issue with the app that havn't migrated to AndroidX?
I am wondering whether I should migrate to AndroidX?
Yes you should.
All the new libraries, as Material Components for Android, Firebase and Google Play services require androidx migration.
Sooner or later you have to migrate.
Also support libraries will not be updated, it means no fixes, no new features. In the official doc you can find:
You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.
Here all info to migrate.
If so, will there be any compatibility issue with the app that havn't migrated to AndroidX
Yes, the same issues that you are facing, but it will happen in any case with other major libraries.
See this
When you upload an APK, it needs to meet Google Play’s target API level requirements. Starting August 1, 2019, Google Play requires that new apps target at least Android 9.0 (API level 28), and that app updates target Android 9.0 from November 1, 2019. Until these dates, new apps and app updates must target at least Android 8.0 (API level 26).
Even if your app is in lower targetVersion if you're planning for an update. Then Google will push you to increase your targetVersion which causes you to migrate from support libraries to AndroidX. Also the existing libraries which will be also updated by their authors to AndroidX. So there's no other way, and you need to push to androidx components.
It's safe to migrate, and an easy process. There won't much code change if you migrate.

Min SDK 19 require any Support Library?

I am developing an app that work from min sdk version 19 onwards. i'm currently using AppCompatActivity, support v4 fragments and support v7 lib..
Is this actually needed for this app?
Can I avoid all support libs..?
Does that increases app performance?
No, you can't avoid all support lib.
It will not affect on your application performance. You can definitely avoid adding third party lib in your project till it is necessary to add.
Please read this link. It will give you more detail about Android support libs.
http://martiancraft.com/blog/2015/06/android-support-library/

Use of Support Library RenderScript APIs is not currently supported with Android Studio?

in the developer.android.com :
https://developer.android.com/guide/topics/renderscript/compute.html#access-rs-apis
Note: Use of Support Library RenderScript APIs is not currently supported with Android Studio or Gradle-based builds.
this means that no any way to use this in android studio ?
my build tools 20.0.0
there is a way to use this in Android Studio, that line in the docs is out of date and is supposed to be removed sometime. however, I don't know what it is off the top of my head! I'll take a look and see if there's a sample somewhere.

android vs android.support packages

Question:
When should be used android.support.* packages, and when android.*?
Would love next facts considered while answering:
Not required to support old android versions
ViewPager and other features available in support-only are desired
If it can always be done in support, then why bother with native library?
Can support/native library be disabled in IDE, so that I stop accidentally importing wrong packages?
Support library is used to make your app capable to run on android lower versions also.
You should definitely read the documentation.
android.support.* is used to support older devices that does not have new Android API.
For example, Fragments were introduced from HONEYCOMB, that's why you should use support package, if you are planning to support Android 2.*.

Categories

Resources