Showing posts with label AndroidX. Show all posts
Showing posts with label AndroidX. Show all posts

Tuesday, October 16, 2018

Hello World, Androidx

Posted past times Alan Viverette (/u/alanviverette), Kathy Kam (@kathykam) , Lukas Bergstrom (@lukasb)

Today, nosotros launch an early on preview of the novel Android extension libraries (AndroidX) which represents a novel era for the Support Library. Please preview the change as well as make us your feedback. Since this is an early on preview, nosotros practise non recommend trying this on whatever production projects equally at that topographic point are approximately known issues.

The Support Library started over 7+ years agone to render backwards compatibility to framework APIs. Over the years, the library has grown to include device-specific UX, debugging, testing as well as other utilities. The adoption of the Support Library has been phenomenal; most Android apps purpose the Support Library today. We desire to increase our investment inwards this area, as well as it is critical that nosotros lay a company foundation.

In that vein, nosotros took a measuring dorsum as well as chatted alongside many of you. The feedback has been consistent as well as unanimous; the organic growth of the library has larn confusing. There are components as well as packages named "v7" when the minimal SDK marker nosotros back upwards is 14! We desire to arrive clear for y'all to empathize the sectionalisation betwixt APIs that are bundled alongside the platform as well as which are static libraries for app developers that locomote across dissimilar versions of Android.

With that inwards mind, tell "Hello World" to "AndroidX". As previously noted inwards the Android KTX announcement, nosotros are adding novel features nether this package, as well as updating approximately existing ones.

android.* vs androidx.* namespaces

Writing Android apps agency depending on ii kinds of classes:

  • Classes similar PackageManager, which are bundled alongside the operating arrangement as well as tin stimulate got dissimilar APIs as well as conduct for dissimilar Android versions
  • Classes similar AppCompatActivity or ViewModel, which are unbundled from the operating arrangement as well as send inwards your apk. These libraries are written to render a unmarried API surface alongside conduct that's equally consistent equally possible across Android versions.

Many times, unbundled libraries tin locomote a improve choice, since they render a unmarried API surface across dissimilar Android versions. This refactor moves the unbundled libraries - including all of the Support Library as well as Architecture Components - into the AndroidX package, to arrive clear to know which dependencies to include.

Revised naming for packages as well as Maven artifacts

We redesigned the packet construction to encourage smaller, to a greater extent than focused libraries that salve pressure level on apps as well as tests that aren't using Proguard or Multidex. Maven groupIds as well as artifactIds stimulate got been updated to improve reverberate library contents, as well as nosotros stimulate got moved to prefixing library packages alongside their groupId to practise an obvious link betwixt the shape that y'all are using as well as the Maven artifact from which it came.

Generally, y'all tin hold off the next mapping from onetime to novel packages:

Old New
android.support.** androidx.@
android.databinding.** androidx.databinding.@
android.design.** com.google.android.material.@
android.support.test.** (in a futurity release) androidx.test.@

The Architecture Components libraries stimulate got also been moved nether androidx as well as their packet names simplified to reverberate their integration alongside heart as well as individual libraries. H5N1 sample of changes to these libraries:

Old New
android.arch.** androidx.@
android.arch.persistence.room.** androidx.room.@
android.arch.persistence.** androidx.sqlite.@

Additionally, next the introduction inwards 28.0.0-alpha1 of Material Components for Android equally a drop-in replacement for Design Library, nosotros stimulate got refactored the blueprint packet to reverberate its novel direction.

For a consummate listing of mappings from 28.0.0-alpha1 (android.support) to 1.0.0-alpha1 (androidx), delight regard the total AndroidX refactoring map. Please banking concern complaint that at that topographic point may locomote nipper changes to this map during the alpha phase.

Per-artifact strict semantic versioning

Starting alongside the AndroidX refactor, library versions stimulate got been reset from 28.0.0 to 1.0.0. Future updates volition locomote versioned on a per-library basis, next strict semantic versioning rules where the major version indicates binary compatibility. This means, for example, that a characteristic may locomote added to RecyclerView as well as used inwards your app without requiring an update to every other library used past times your app. This also agency that libraries depending on androidx may render reasonable guarantees virtually binary compatibility alongside futurity releases of AndroidX -- that a dependency on a 1.5.0 revision volition soundless locomote when run against 1.7.0 but volition probable non locomote against 2.0.0.

Migration from 28.0.0-alpha1

Moving your app from android.support to androidx-packaged dependencies has ii major parts: source refactoring as well as dependency translation.

Source refactoring updates your Java code, XML resources, as well as Gradle configuration to reference the refactored classes as well as Maven artifacts. This characteristic is available inwards Android Studio Canary 14 for applications targeting Android P.

If y'all depend on a library that references the older Support Library, Android Studio volition update that library to reference androidx instead via dependency translation. Dependency translation is automatically applied past times the Android Gradle Plugin 3.2.0-alpha14, which rewrites bytecode as well as resources of JAR as well as AAR dependencies (and transitive dependencies) to reference the novel androidx-packaged classes as well as artifacts. We volition also render a standalone translation tool equally a JAR.

What's next?

We empathize this is a big alter for existing projects as well as codebases. Our intention is to render a rigid foundation that sets Android library projects upwards for to a greater extent than sustainable growth, improve modularity, as well as smaller code size.

We promise that these changes also arrive easier for developers to break features as well as implement high-quality apps inwards less time; however, nosotros empathize that migration takes fourth dimension as well as may non check into everyone's production schedule. For this reason, nosotros volition maintain to render parallel updates to an android.support-packaged laid of libraries for the duration of the P preview SDK timeframe. These updates volition maintain the 28.0.0 versioning system that began alongside 28.0.0-alpha1 inwards March 2018, as well as they volition maintain to locomote source-compatible alongside existing projects that depend on the android.support package.

The stable loose of 28.0.0 volition locomote the terminal characteristic loose packaged equally android.support. All subsequent characteristic releases volition simply locomote made available equally androidx-packaged artifacts.

We'd dear to listen from y'all equally nosotros iterate on this exciting future. Send us feedback past times posting comments below, as well as delight file whatever bugs y'all encounter on AOSP.

We aspect forrad to a novel era of Android libraries!

Sunday, October 7, 2018

Androidx Evolution Is Straightaway Fifty-Fifty Better

Posted yesteryear Aurimas Liutikas, software engineer on AndroidX team

AndroidX (previously known every bit Android Support Library) started out every bit a pocket-sized laid of libraries intended to supply backwards compatibility for novel Android platform APIs and, every bit such, its evolution was strictly tied to the platform. As a result, all function was done inwards internal Google branches in addition to hence pushed to the populace Android Open Source Project (AOSP) together amongst the platform push. With this flow, external contributions were limited to a narrow window of fourth dimension where the internal in addition to AOSP branches were unopen inwards content. On summit of that, it was hard to contribute -- inwards gild to create a total AndroidX create in addition to testing, external developers had to banking corporation lucifer out >40GB of the total Android platform code.

Today, the orbit of AndroidX has expanded dramatically in addition to includes libraries such every bit AppCompat for easier UI development, Room for database management, in addition to WorkManager for background work. Many of these libraries implement higher-level abstractions in addition to are less tied to novel revisions of the Android platform, in addition to all libraries are designed amongst backwards compatibility inwards bespeak heed from the start. Several libraries, such every bit RecyclerView in addition to Fragment, are purely AndroidX-side implementations amongst few ties to the platform.

Starting a picayune over 2 years ago, nosotros began a procedure of unbundling -- moving AndroidX out of Android platform builds into its ain course of teaching build. We had to create a bang-up bargain of work, including migrating our builds from brand to Gradle every bit good every bit migrating all of our API tracking tools in addition to documentation generation out of the platform build. With that procedure completed, nosotros reached a indicate where a developer tin instantly banking corporation lucifer out a minimal AndroidX project, opened upward it inwards Android Studio, in addition to create using the populace SDK in addition to populace Android Gradle Plugin.

The Android developer community has long expressed a wishing to contribute to a greater extent than easily to AndroidX; however, this was ever a challenge due to the reasons described above. This changes today: AndroidX evolution is moving to populace AOSP. That agency that our principal characteristic evolution (except for top-secret integrations amongst the platform šŸ˜€) in addition to pƵrnikas fixes volition hold upward done inwards the opened upward using the r.android.com Gerrit review tool in addition to changes volition hold upward visible inwards the aosp/androidx-master-dev branch.

We are making this alter to give improve transparency to developers; it gives developers a direct a opportunity to meet features in addition to pƵrnikas fixes implemented inwards real-time. We are also excited near receiving pƵrnikas cook contributions from the community. We accept written upward a curt guide on how to become near contributing a patch.

In add-on to regular development, AOSP volition hold upward a house for experimentation in addition to prototyping. You volition meet novel libraries demo upward inwards this repository; roughly of them may hold upward removed earlier they ship, alter dramatically during pre-alpha development, or merge into existing libraries. The full general dominion is that solely the libraries on maven.google.com are officially ready for external developer usage.

Finally, nosotros are only getting started. We apologize for whatever fossil oil edges that you lot mightiness accept when contributing to AndroidX, in addition to nosotros asking your feedback via the public AndroidX tracker if you lot striking whatever issues.