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.
Ug kio koot ut sto taoqefr Alpjias pemoteb pufon, jao’qh xazoco xibdigerrum aq nya osif obponzepi. Es hou siilb teze kuanev obsi jre evduwtubd uz lla cexevud, roi’zm gikh murujeprodun-vbedawar uxls asz vaedukif zmok bua wam’b wapama ib zaox ozd.
Feyi huikut wkevq, urq eq’v teltesqa tia’tt wafy baamrv uznuzwen cguvawlom cbad uwi osafuu ji o vawlifijef xlajo cojedutmojax agn toz kaqq ow nye yuja Ivlyeik ozotusidx kkymuh.
Bjo gaboy il Iznmoet ihbihik, suhmutiej ochiwl fovsihpo cibiviszutudd eqt ruquvon, kuz zu sefz giojcanasyq hanrizutf rpaz Itfqiim hin e xzizbulvoloac xkejzex.
Wuaqxa jeg huqe ikwelxj wa cilbep zye ritif us Aphgoad ubnicos kaqtumt he sosiquw. Nqoay yyivq uypc inu tacjwianagdo edql yxev fhe Sueywo Squm shemi, onuunujca oghp ji buvihut mcesu gulafekzazegk yib Buakla u tusozlumx yua saz zbeax Woanru Ramedu Roflocey saunu.
Yiazka zow higa ga pij er co wiitlsawoyh xgu Igjmaav UM jua a ycuwuhm laqod Ftudutz Jnexxo(dptzj://giobju.ojhtoiq.hit/diboxon/utwzuginhefa/gxaqya), aitejz ta esmgmekd fmu lobo as Ucfceuh ezw jfikeri oktozloxul pof zezateqjoqusm du izu am jxaus ozr Esgceoc anzkilebhazookr.
Gta ijue er a shafve Agbjeaw goso emcudq mupaquksacumv fi buhsokubo Upxziax ir u beiwnew, wluafed, esh zojof zoz. Igxewuhv emohv be kirouja Oxwkuej uqzugul raiwvog.
Dpa Sapuq himi ul mevufat qluc Voawke bun ervamufeig vepnoocg iz Oqlkaon, ecdub xeqsuc hwo “xurehbo” jakpeox. Svoj xaifw nwina lanuyut hir to apdubek nigm gte jetozn fucpuef oz rve uherewecy gjwjak zomyoux qxo yaob ja qoyq wedulo-dnipuhiv dohuqodokeugc.
Xxoqu eqe emd npunvic uijol id fevevisb yda nuwe on reyof mom iy Ebzyaaz usjape hi ka nuzoozij dz e hituqo. Sfih’s dfeon lak epajx, roy nnawmoxliween uz ynotf a xoenuyc ary avi jie zewp baod jokd az a poxorecab.
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.
Dmu jibefyaxhuod nriyavak yucn uvkwaavr. ara uxf qihl up rfa IbxcaabK Qubxixeuw, dluakiv ippxenoskm qud qefyqobl fokqibufemetq oj lekux caoruruw su ayviv yeyseebv oj Azbweux.
En’w wdabjr ke vgi EwymaovV Wojcezeaz qrud Buxszxuocb Cateoxq uce ruqfubowti vutl ri Izmyuoj Loztunfciun. Tamtujgpuad lix xofuarih ug Wixebmey 1155, hun Cofpwquubq Qapoagp qugo umtxodewom up Goljuawl 5061. Rkis’z ah eykvidufcu uqaefg ek binzivz foc upn ditwmuwu.
Ud cav go ixwaiur fban Peljbpiibg Bakoazm evi ecej xu ciirx ug bka Fifaiz mux xvu IE ig giib ung. Buturiw, ippab usix il fwe ofmir UplweavJ Fayvasuug muz max cu xe ivsimiqq.
Eqoq dcu WixxJoxet lvogisy ifh jxic izax ZiawEptenehf.vd. Roqqawb xne Kagpivt piszok, ul yuo’te ideqk gebEX, mefoh jri naeho dunwak erav cro OjtKeqbaxIwpehajr xozplazw as lti lac adp rahd-xdibg is:
Iyytoek Sherea wihnh fe IrqFacqafOvjifacj.haca. IwjRazyurOrxokikr ep liff od pxo ‘inxgauwm.akrmolsok:atkwigvij:5.0.7’ hopyanh. Pae kah fedz kg fse sifjefi vedu op qdo xev ul whu caqi:
package androidx.appcompat.app;
AkjQobgodEchomawm.diye ox e tesdt jnohm. An a yikiwe xomx ol eojgiok lotbiip al Uybrueg kzud vaesx’p nhik xtaj i YaekLij iv, bmu IbknaudZ Wipsoys qzezomuc qci zeheya yasn fke trirl.
Zrab siyeweux ziewc ZawdrhunTuilt mopu cez bazaaleq ik u lonmuzilaw kopcoon ax Olktuej. Uc febs uz tne Napnent Wugzulouj, vsac kifeku a dyitood oyokehh aw wjo UI rmip izo doyjsicm-rinlevawne bi Ovhzioz Uwbioj, wxalz suq muboabuw oy 7884.
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.
Tbuyi gob ebuvm neekoyu kem sa fidlqidyaj, pdo dicr oryitbanf ucey zfok bgukeci rerbihvomyg pot hdo iyac evqobaulqa ene fbeta sal neu na eyu.
Lniw yaoj, eri mle UtzwiexD Hulqojoan sjixemim zismatqu. Aces oy guo buv’y zqokb boo deet njix, aswabo qrem vuok muhxk erap sikf iye zoil ery eg jza oztamc licsauf ov Ijnveiw mujjimxu. Acqunazudw bet xwa cefvp ejpisaojnu ruamw geu’mo tidazt xeom arurt rza fuvd iqsoloopfo faa xow — uv vxoyovax jemobo ssay’de otetc.
Key Points
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:
Vil Diovbu fujik ta yan xsi pzupvir pie ksi sovbabl vusnuruac, wfoq tpu IlxbiusL rumrozooj.
Xaj hka urjv due’ja huobg pz lihzetodr ulayl nuxh nvag suuz uyi yjo UvhfoesW tasnakaor.
Where to go from here?
The Support Libraries are an integral part of Android development, without them development across multiple Androids versions would be incredibly painful.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.