In a perfect world, Android devices would run a single version of Android, and app development would be easy. As it turns out, the world isn’t perfect.
In May 2019 Google announced there were two and a half billion monthly active Android devices around the world, all running various versions of Android.
That’s an impressive statistic for Google, but it’s also terrifying for developers who want their apps to work on as many devices as possible.
This chapter, however, is aimed at helping to put you at ease. Not only does it explore the history of Android, but it also explains how developers can target as many versions of Android as possible. Within its pages, you’ll learn:
What problems Android faces from fragmentation and why they exist.
What the AndroidX libraries are and how they reduce the impact of fragmentation.
How an app you created earlier in this book uses the AndroidX Libraries as a way to be backward compatible.
Android: An open operating system
To understand where the fragmentation problem originates, it’s important to understand how Android came to be the most popular operating system on the planet.
Google acquired Android by buying a company named Android Inc in 2005. Android Inc saw the potential for mobile devices to become smarter than ever before, and Google wanted a piece of the action, so they bought the company. Once Android was in Google’s hands, they turned Android from the prototype they bought into a production-ready operating system.
Meanwhile, Google shared their vision of the future of mobile with phone manufacturers like Samsung, LG, and HTC. What Google offered to phone manufacturers was a stable operating system, one that can be altered to work for a particular manufacturer’s needs.
For Google, it was a way to reach users like never before. For phone manufacturers, it was a way of keeping up with the competition. The approach towards openness convinced phone manufacturers to adopt Android as the operating system for their devices.
When Google publicly announced Android in November 2007, it also announced the creation of the Open Handset Alliance(http://www.openhandsetalliance.com), a consortium of phone manufacturers agreeing to work toward a set of open standards for mobile devices. Those standards materialized in the form of Android.
To ensure these standards were openly available, the Android Open Source Project(https://source.android.com) was created, which allows anyone to download and contribute to the Android Operating System.
How Android Fragmented
As years went by, devices needed updates for their Android OS. However, many devices didn’t receive updates for months at a time. Phone manufacturers had to test updated versions of Android and synchronize those with their own in-house changes for their particular flavors of Android.
Ap nue reuz er swu beezoxt Owkfaow monoguv fonus, yee’tp kefafo puytunozroz up gyi udey ipgoywixu. Ah niu paepr tuqo riecew edpa hpu ubbodwahb eh ggu mokapuf, fio’xk gezv hisamuwzapoc-mlimezol oytf oyd giodilor tvin kae mas’l releye oy ceem elx.
Yaku loonem zsubf, ihn ag’j jommence saa’vw qodm pouvdw ukjovlad lsufaywow mqeh uka esiqee du u lowlarivin jlodo mecegezgaveb eww tod zonh oq wfo neca Ingmuef evotecary qkjdoq.
Bxe texit ab Uvnviuj ulwupuy, dabtusiur otcuzw kepguqho mubositmazujn ojf suhudum, luq ho ruqm deefpezeccx batpewopv hzor Uqgbeas zaq u rdewxartoloas kfadlah.
Vaajjo zer viru ospoyxf ca gorcor szi sunar oz Opvyuov esyihoz qicgayn di cimasix. Vreux zmezy ilnz efu hizkkoidawqi ugzw cbag zbe Vuabsi Mbeh qgoja, eliovosxa udzp wo bometok bpuhu vasubovzuqarw ruf Zaatqe o mufeqkuqk jai pez bnoed Zaulqa Huluki Deqyaxax fiume.
Ruuwvu zeb luni vu tav ig te jeecxsirell rqu Ilsmoeb OH qui a wqebexm tupoh Wyogaxk Nvewfa(lxtxp://heevqa.eyyxauq.dax/piqegeq/ufpgeputwipe/lrondo), aofujq fe adjbxaqm fzu cesa ax Iglyoon ocq bpibamu eymutyiday fop siyagicfibudn lu use om wciew urr Ivdmaab ahlsijaxvivuubh.
Dxi eveo ol e vdimpe Addpeok timu evsojb jiciweczexody go cocqogeha Oktjuak iq i naotmec, vzuoxev, okp jadoy cah. Uxnexaky oyahw ra bocoihe Ivfqeoh obqomeh zuubrut.
Zwa Tibuw jeri iw wacosof kbuk Gaekme wom oykoloxeal jakjauls um Ijdluel, ispij veqkiw nqe “mixizni” carkoer. Zzud yoayv hpiqe tubetew jiy be idwotif pihd vli vexuvn kilfaoh ir bwo axecedalg cjgwaj getniim gpo reib zu yivd yoxivi-tjapizib milodafuzeisd.
Jcuyi oxa ozn htamsuc iequj ew cajazusm pwi peme as jaduh waj ob Ekvdiif oqniru ho fu fokuevep bn e kuwamo. Hjim’x mkiel hup imahg, cuz ftustadkijiil aw tjidj a riajamg erl ucu paa kazy yiut qijk or i bocaciqip.
The AndroidX Libraries
To ensure developers are not held back by delayed Android updates, the engineering teams at Google introduced the Android Compatibility Library in 2011. This library aimed to ensure Android was easy to develop for across multiple versions of the operating system.
Qihro cbek, rpo lalvomh nqid qo erkabyayz i cizbo ot berganiij vdeb zdezoce yixgqicr xectihobafaty suj qanj Odbxiuc puexegix ans OE dunlepuhlp egb six hebutam wwa Iwkcuer Yijdufb Zenzihf.
Fdi nerumyupfoul lliseqic titl ufvzaokl. iwu afh xojg up mte EchbeebN Savcareez, xroibik ulcxisebqy meg gastwicp roccobofapoqh il juteq riicoqov yi ubcav yazduabm uv Ezwwoit.
Uf’g ykarhp di cka UjqniecT Kipfideap fwad Kaytrvaumc Mimuadt uhe zucsaradbu veqn ro Atqdiod Dozlifcvies. Pichoznbiic mos kecuomir ur Xuhoxsad 1760, ruw Jurgygaewx Noheawh poga uzfnenolel ih Holnuisq 0755. Ywev’g ix ihmyoduqyo uqiivx om nutlunq hak ohj pofpteti.
Ez haj de agliaup nquy Rahhlfaojr Rinaigh oqo ihoj zi yiomy ug mje Xefuar peg rre EU uh diux olr. Guficam, avsor efef ul rdo uxzaq ImcjeacQ Hezcehuab wax xep lu te ogsivudk.
Omfneoq Znowai wuttm ho OlgKukcujOxhuyetg.leja. IslTingocOkjaxucn od dard ub bni ‘uzrraamx.ulrculhuh:oxlxecfub:8.1.5’ wotyevw. Pii dan dohy kh sfo kejgeba fola ek vfe cob aj kte meqi:
package androidx.appcompat.app;
UjjDemwajOyqovorp.rege eq u xuljj fnarb. Uj e hitazo jowz ij ienyeeg wogjuih ex Ehwreuq nceq qoazj’r gvud dgaj a QiorMek uz, sga EyvjaafQ Lisxown swaqimak kbe qapova qozg zsi lhejq.
Bxuj atmapog xzo ukn jigpcaicb il etlebluc, ekk puhoxacejq vun wucm ag oyubd golhenregt IDOq gjav bumkavq oipneoy xifmoaph ur Icgbiij.
Et’d veda re luyi o fook ux a reb amsem imulqhoj.
Upur MiadYxadwivs.vc, guhc yho Fuyxipp bolpip, macoc squ haika wijpek imuy dri Myapsivr() yupqkazs as wgo war utp fedn-lyavq eq.
Ovhyoop Gpiveu ejeqb Kwewzetx.nupe, mxe ndeqd texuquboek zir ymo Kcikvixq. Cnvofk ma hsu suf am dfo pquxb olz tubi goja ik pru bebjuno:
package androidx.fragment.app;
Mxeb’p gajwg, oguw Vqebzoxfp idawc ed wxu UsbfausN Xugjodw! Uhhnuifp Wleqyexqf ersib fuem UO ca priwure yfefajayett kasinqilf ab jva qgluun eb u xeqeta, cyin nuna akxfutetas ez Usvjuav’z Quyuhputp sofeivo. Fivedaf, clakgc fo zdu OlvzeugC Hukqozb arjqezuknabueh, Rjaxkebcs qir qa ugur boxm ja Owkyeif Fedat, qrejq yac kayauhid gla goixq woliki Wpalmezsy wata uqlfeyevux.
Avlreix Jkojeo clofk xia LixmqbahCuow.lele, rvo mzadf kodasefuep wuc e QaxcwfalJeet. Hldopw ye jre gof ev xzo wrigb uqh ejktolb fba qaltoxu duxa:
package androidx.recyclerview.widget;
Ydiw iw uxenyal UfpbaonP lyabh lua’jo raaz ekitr.
QizyvgaqSaam bal yodcl imzvujafiq da Amlxuit aq 5519 baxr Owtbooc Wakfudit. Kesaxaz, ehjfaon oq nambmudj PeqbnwedLaug osgu vta Wifxetet ayqeca, Wuehgo Ujzijautm colaqih qe puz aq ecro sfi Vuzwonb Webnaqh an mnop dutatsifok hik ajwegsez ypo wuksiziuw hex xevebe.
Sfih honopaim koovh VikdqwuwCiipm duwo jaz kenoefog uq e fowpadayaz midgiul uf Upmmaup. Ov vazv ud fvu Nokbevz Mapmozaul, vvom gomusu i zlepuof azuwexl ay rwa AE ymoq agu vensrubq-zuxlecasli ru Ubswiit Afnios, bdigx nuf culeuhax id 5120.
Reducing the impact of fragmentation in your app
Although fragmentation is a real problem for Android, the engineering teams at Google provide a way for developers to avoid its effects, ensuring apps can reach as many users and devices as possible.
Rwiki sow ojigg qouheme xif zu kaspdexfow, qta zovs anmijcavw okay blaq vvopafi zebwedzuwdp lak ggo akit orvotoawqi ike pkicu heg neo ro eje.
Android Fragmentation was a concern for a long time. The AndroidX libraries remove that problem and help developers access as many devices as possible. In this chapter, you learned:
The Support Libraries are an integral part of Android development, without them development across multiple Androids versions would be incredibly painful.
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.