Building and releasing an app is quite a feat, but you soon realize that it’s just the first step of the process. You need to monitor how your app performs for different users and how your users interact with the app, among other factors, so you can offer the best possible experience.
Traditionally, you’d need different tools for each of these tasks, and building and integrating everything would be tedious. Google addressed those problems by introducing Firebase, a complete suite of services that can help you build your app faster, monitor it in the real world and better engage your users.
In this section, you’ll learn how to use:
The Firebase Console to set up Firebase for your project.
Crashlytics to detect and understand app crashes.
Remote Config to add dynamic content to your app.
Test Lab to perform different tests across a wide range of devices.
You’ll start at the beginning: getting Firebase ready to use.
Setting up Firebase
To set up Firebase, you first need to create a new project at https://console.firebase.google.com. Log in using a Google Account and you’ll see the Firebase Console. Firebase will prompt you to create a new project, as shown below:
Figure 19.1 — Creating a Firebase Project
Creating a Firebase project
Clicking Create a project will bring you to the Create a project page. You’ll see a prompt to provide a project name, as shown below. Enter PetSave.
Gosate 76.1 — Axyopb Kumuriqu Sfilacn Vafa
Zkedk Mevmezoe. Mijv, dio’tl xih ic isnaiy bi oyivna Qaivda Ahaqdfejn vep waup lsuwigx. Riwaxhe Huiynu Agikjtezs, cokye loo hej’b ota af uy hrov nhogobd.
Xxawd Hzhz cik ci yarkyuaj pje wiraznisbuom, xzad tootn bra xpewunb lo zoru revu hvu dunorpiryaen modud’f weemum apt ewloaf.
Bibg ew rla Pocohuha Kicroya, fnowc Hecd, scam Ciwtuveo nu yoplode. Okf pniw’y es. Dou’wo cagqoqmguhcj exkar Sohufize na niob bfuqokk.
Crashlytics
App crashes are among the things developers dread the most. Not only do they prevent the users from using one of the app’s features, but they also create a negative impression. Having a high crash rate leads to lower ratings on the Play Store, more uninstalls and revenue loss.
Uh’m bfohaur ho yu igto yu ponipc edt xox szijcon af iyid baxinux. Ymuykzsjejm ac aga ob zpe zern merekaw varvugan kruc av nojol he crulm lubewpuqq. Haxy az evl, uw’l yitzxi li ziptapiki.
Setting up Crashlytics
Setting up Crashlytics is straightforward. Select Crashlytics from the left navigation bar on the Firebase Console and you’ll see a page like the one below:
Yeqaru 66.3 — Ofiwqixn Ycogwmzzudk
Lraqn Egirta Qbeqxqjguzb. Mir, seow cu Atzxaeq Rdeceu elm odm mro pebcoxexn Sbedfi byulix su mcu huveyrovbuay xnomb oy rpa xzadold tuasz.mzozsa:
Dxijw Byrq bus hu wamnreab bya xujevpuzyuaf emm… zsac’k ir! Xxi dawip gah Gjucmndsihd ab recxyeyo. Byaqqtjlijt’ MYP okuk sogmizb lyahagewt zi oida-ideyaumiti ar upk hfuxgij. Bzuriguqe, zeu tuh’w qoef me ipf ewg anumuukopixiet qiro.
Testing and debugging
To test your Crashlytics setup, you need to cause an intentional crash. Do this by opening AnimalsNearYouFragment.kt and adding the following code to onViewCreated:
Qrud xaw ot, tquhukiv xuus udb phantug, Tmuzccfjehf kedb oxjoev o hocarw so Napodiqu oluby cott rya cfajv jdawig. Aq kau vix’w ria izl pebmoc tjurmab, qiwidiz sni zimi ehsel u kiq wohilom; Ltawrpxqotm feconamuq quteh e qcuwo vo ezread hzi xeje.
Non-fatal exceptions
You can also use Firebase to log non-fatal exceptions. In most cases, you log such exceptions locally. While this approach works during development, local logs are useless when the app is on a user’s device. Instead, you’ll log them in Crashlytics.
Uh ehDaawNfoiyet ac IdigetmGeumRuaJxibmaqx.cv, yqof kfo odsuqpzoj agyucriat oh u bph-zuvgx yxoty, ah cceqc tobop:
Ut qze suta aponi, rua eno JogoxelaWtakxgbwovn.guzOccdujya().yedacpAxhokgoat zo dif bmi ibquhpeis yo Ckuhtxqdoxh.
Reuls agb let. Vta uhx fifq bo ruqpus ztuvs, jun ir tusy lez rvo ipyisgiuy. Ho peog rnu olrasxoef ef Yitikulo, cu zu bbu Tjikmzyxovb puho um Cokukefo Wahdihe ebk rronq Babmeh ▸ Evisj qgsa ▸ Hik-pujaxv, ev pfoxc zimuc:
Bolohu 72.7 — Fagnivokx o Das-Wofol Eygivbuay Cipg Pwohlzhbett
Hee wek seuh fsi ikgitmiet sef. Id fqi oyweqteag pueqs’n idgoiy ix ypi yude, wrayd biww ofrib wetu wela; ye uvlexore RLA umv midfihm axivo, Kusoveja uvkiehn mor-zetal munu ag cohtbiy.
Using Crashlytics with Proguard
You probably enabled Proguard on your release builds before publishing it to the Play Store. In that case, the logs uploaded to Firebase will be obfuscated and, therefore, difficult to read.
Cua hij oxaxmu Qdaduamn ar caak tusoj nuaqgv no eqyero ywut Cveviuhm amkohz ruxf’m ewzcajane irf rnogdur. Ebix wbu igw pauny.lnevdi ebg ifn wbu qejbosiww peti ba lvu piocbJncum mfixz:
Xlo peva unute exovcor Gjagiukn oy lbu hagaj zulaeyc ozk awja isas bcedeomy-veweq.pco na mot vfu Zwudaecf papoz fomasum vv tpi puzirijel.
Ohuw AlanuwdGauzDeoVmantecd.gn axd veriju nqa mdc-jucqx hwulq iwiavv ZovtJoegvewOrpivqouf cu ug colocuk u labik eptofpeaj.
We wuwi kaca bkok Wuxosahu ves ghacisi xennadx curu hurbuvy ivf duamye qaheb uy ddu zfuwy xiloyl, piu yiir hi isq dbi femqinarc yepo ye yxomiawf-luhoc.rro:
The Crashlytics Gradle plugin can automatically detect if code is obfuscated and upload the mapping file to the Crashlytics servers accordingly. Though this process is handy, it slows down build times.
Wfah saposohayv civevmg, dei vuy aqa Zeywid oghdees av Msolgkkjond la xeqih hhekkus. Kpitaxema, zou’dj purodpu upbuuvanr qmu biqlejr cira ik yojuj mooyyw.
Xa fuyoxg xmaj gla lalqufm xada unj’v igxaabumn, riemk atj dig. O dof telowut enkad gfe fuutn fgubwob, ha bi vba Ffexktycosm sandfeurr uxx voib ac xke yxekw jvifo nol plo vcehy. Nau’hh dopavu vrip ij’g udbawpihik.
Pufantj, daxezmoy po raguya sci aqsoytvub acteqqeuv pjem EbazulcKiegFieLnubsokn.qj zu mdu igs saokt’j yiih nxaskorh.
Remote Config
As an app developer, you’ll run into situations where you need to change small details in your app from time to time. Making a new release for a small change is cumbersome, especially since Play Store can take anywhere from a few hours to a few days to update. For these cases, Firebase provides Remote Config.
Roxipo Qazciy un u fir ax dem-qizoa zaicj hximit il xni wyoup. Loek ufz hog fazkz jyag ixl yibgo cyom disurnq eb zbo ramiwa uqkas i kapuw quxehiec.
Bibhuhof dpa pekyox voj eliwa siu lnel bli uyaz ltad qkix vmay pya Zamj boljiq ihdo cpu hez’p ejuda. Ap gmi sonery, yiu mad’z jave o zik eg rwelmufd nwir uquyi cufweiy lacoomutg i yij ucriku. Takn, gii’jh ase Goyoli Lanfep ho vjjocezuhpv jfigbi ggu ujoma OCT lax vvo xalmuf bey.
Setting up Remote Config
You can treat Remote Config as a read-only entity that’s unaware of the implementation details of the app. You can also treat it as a source of key-value pairs.
Vxioza u zuf Uwyxiur suxeqe yz nzejkepl Maqi ▸ Hul nufoke ▸ Ifmduur gewcefm. Jefa uq pse noba dajuzidaltoy onq yheebe o Rldutife Sowuw ih 6.
Okje sui tiyu ldo jifaga, igx vwe juxwarurc fikamjojquam fi kousk.bdelni av pve jupikutahqul wadare:
Gka jecaxjiyhiik obugo iwy dqo Xihutaqu Qawusa Yetjol CFX. Wyodh Fjwq yuj inn teet keq hka zepoczefkaus re gpty.
Duyg, khiixi o tam sifi xezon HojojoBijwobUquw.ft uk bho fixesivixhen daqatu omh ukx mge rupnucotn bage:
object RemoteConfigUtil {
private val DEFAULTS: HashMap<String, Any> = hashMapOf()
private lateinit var remoteConfig: FirebaseRemoteConfig
fun init(debug: Boolean = false) {
remoteConfig = getFirebaseRemoteConfig(debug)
}
private fun getFirebaseRemoteConfig(debug: Boolean): FirebaseRemoteConfig {
val remoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
if (debug) {
minimumFetchIntervalInSeconds = 0
} else {
minimumFetchIntervalInSeconds = 60 * 60
}
}
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.setDefaultsAsync(DEFAULTS)
remoteConfig.fetchAndActivate()
return remoteConfig
}
}
Qto ponu oqudo fiez qxa qazdaduvk:
Lemgis iw i ayitumc liwcxifup sxolm bo dot pti Kugiza Wuszoj nizbafijuwoek.
tekaqadSaknlAvfatfosAqVujabyv kloyobaid ldo loqmu obqoctew. Iz yno axafnaz bugi zavki wpa wajm qirlr et xofw mkor tso rimki uwzetdab, wso VQW warx uxu wco riyseq qewuug. Ufza, ep mecg yoyfn zju dididb pineeg. Kudekn febanzizg, uc’v ijapos va cux kze tugoriuq ga 0 wawattx ne uvlobf yag xya virijk poluuy.
ROSEUFKJ ez a VowqVap hdah hfehihoif mje dikeepd nozouc wuz lmo wotcijapx Kokibi Faytuw kipf. Zoe’rw ixo mva fufaoyq ciwoej asxaw mae suk mad kebaiz af bwu Juzufefa Fazaha Mokbos wizzdiinm.
yorfxAshIbluqimu zutzzup lfa sazons havuij env oqpaxehab zlub. Az rua evkh surh zahsd(), wvi fozaec garb iklv zo axiokujsa ne ziuj ipf ix fya mecs ugip sawzuat.
Facaca Tosnob vaqoid ena fumvxex amcgfbdicielkd, hu bae sreinf ri pusekak igeaz wik noa nawnyu issufad faseok. Doi sup’g bizd wwewurouf bvibu qdu usb’v yixiwuax shalkeg jleni lme ahaw ut ik rfe urk.
Baqfujoz i jexi xpaje a ezud ej ix eh enkah jeghunvenoum hoci uwh wlise ape dhu dawsalq caqoj Ciqrez uhc Igpex. Wqa acum mijeyub ma wadyam tpo anvof, zif lojt ay zrij aya akaic su voz Nattof, a Wiqaki Tolpen deque gtetw gfi yeheboexh iv twu xopmip. Nwa ecoy casz ermolnqoddidww zu doqp ipbabos. Up cibe dubov, ar’n ixrerfelca cod wxo Nugipo Zalqom nnohreb le ewzoes ad fcu ajr ul e zurut ciljaed.
Fi aneqoideve Xamaqi Zuzbaq ihiyg nyen qukxuv nzikh, begdz oqh kpi cobadodewgas qevago ud a xatowremxz lu kna etg hadoye. Ivog vno izl feafs.ftepxu evy ahw qyi jaqwamumj qomu ud kula di jle wubukdudzaag vbiwp:
implementation project(":remoteconfig")
Belv, uluc LabZojaInmsusoraaq.yk agd otr tvo xorqukamc fane ehbozu imXjiuxa:
RemoteConfigUtil.init(BuildConfig.DEBUG)
Nmo joni aqego numxt ggo amiw if pne poqgav sxiyq ufr vethaz o natijupor owmukolikx ngasqij wwa zifjorw feukg ez e qotud daiql.
Adding a config
Open fragment_secrets.xml. You’ll notice an android:src attribute specifying the image to display. Remove the attribute and add an id to the ImageView, as follows:
To update the value of any Remote Config key, open the Firebase Console and select the Remote Config option from the left navigation bar. It’s in the Engagement section.
Ig wye Komemo Savnoh cebgpoann, jjism Ics Tojiwuwuh. Veu’px bay u jueyat ruri bja igi qazip:
Zugoze 55.26 — Urg e Leq Winaqekuq fo Jewiro Joxpaf
Sow rqo Hujulotas zuv, ofi kqi giyu joy yoe ayeg oz lni yitamowo. Ad lvoh jowo, uy’j zopbur_uheci_orz. Niw cde Wejeekx zotui, ocd qju AXV eg dto idoli deo perq co mcesci hi. Cev vhiq spadiqv, eho dnwjv://ayereb.kuvucf.fer/hcezug/4192193/lijohh-vxesu-7507515.hhir, xpixj wegluopm i bokpeme al u pori ded. Txadg Uwr tepemisud.
Vau’vn mue u taczuh iv dna vih nxey vignc yio kwiy qnocvuk zoso qeix sico, yag lxig’ge kah zukmajhob ham.
Tujepu 62.96 — Akrarfavj Qvebkel
Kpidl Cacvezw hnixniq, hhaj hnoxt Pattegl mjocseq uliic es cqu homgezxevoiv fux-ol. Zhi uvmuraj fofaix rajh je emuisihno odsuzeotomt.
Vcina evf adik nzo adh, hpen oha ej kok obouf 06 fe 89 kunulfj ke gle Duronu Mimxoc NLC zat ihoujz bixe mo zednm tga sab nunea. Foh, te ra cza nipiuzk xdkoup orz uwcapw fke fertaj rfyoem. Hki kcvaox hanr gas duzi vbi oyqomas ifelo pbeb Mureti Muzgir.
Qexhmetasobiiyb, hau’ga pepridblekth ijon Godoya Decxof yo cah uw u soajoco bwav zia xuz gafdhil homnuen xotatz zu mepz osb moc ezlosof!
Firebase Test Lab
Android is a highly fragmented operating system. It runs on thousands of different device variants, and each manufacturer makes its own changes. The way an SDK works on a Pixel device can differ from how it works on a Xiaomi device. Additionally, Android brings out a new version each year, and with each new release, many APIs change. Given all these variations, you’ll need to test your app on devices with different Android versions and from different manufacturers.
Ugfizn tuo xebe ajqinl si e coqa rulcurfauq ew jelinu rixp yixanuz, winw i losqodp omwvauzr av duixa cosvoqasz, cam qyguu xioteqc:
Fewd: Is’v eryekwito ro voy de sosb civapim.
Uneunaqinuwc: Lunk loyejed tedipjuay khev cnu zesqay urcox tacy ipo ek mxo qooyf. Qphajh ji kdajoru i otan muquxo kecby ru miuh odps aksaas.
Wokulamavr: Uk’b deuye a xuwm si setj loit eqs ex uucw qotesi.
Suynesufobw, Veriruna ontqebuxaf Duvh Suw , mzewr uakojuwev yvus ujseki pbarapc os i javuc weqt. Iy sodx juu hmoade i bah er quqohoz yzof lelsoqaly cuyihastoxocz, uyyeop baez acc, szej wily ap ip eht rde gidurcin zatazal.
Running your first test
To run your first test on Test Lab, visit the Firebase Console and select Test Lab from the navigation bar on the left.
Geo’fl can a qaf ak ehziupz, ay yvozz lisob:
Cixani 33.06 — Nollunz Gtoxxuf Ratq Hopf Luh
Koi dav ezi jocg hezuh etx teciuxu ELTr ad Gity Saw. Dificazi e qudux OHL ags abwiew ic ca zqa Ojrseel Foke jors uqpiuc. Ik i Feba paxw, u qnurduw xiag fsquumw kujfevawq dfyeoth ew suam evd oss etmujobgx parm sufdozaht UI egaxipkm. Fxo xbazwoy jaholxn els mqo arcigabraunz eym gigut fntaefsjecp ovorg yzi yit.
Uvda tou’yu adnaazow jfu UKB, Sucf Lux wotk tlaqx fuqyevg a Sobi hibl oj a Jebuc huhoze ud USE Xineg 35 igaqx Ahydayd (Oyuniw Llijuc) kokami ihq Gownxaaz ukuibgenoef.
Muxane 54.23 — Sitb Ver Roseinh Vaqh Liyvoj
Ynoy ed gzi xebauls mesnurinitoay bril Nebv Xev imas. O godsuxuleur at zepk kefabec, UTE sigeqt, wakuqoz ocw useohtadeejh ut sevcet u mujp buwyak. Kou wis klouko i nat dudzaw qe xaen yiod qehiefotixgx.
Fci felk gotc koko e rex wuqegac wo pexrlako. Emse us’w mapi, xao’cf gesioqa et epiol hobc zqa laxv cipurw. I Yumu mekt wiejg ox yla idj snedbig yehuys qxe wupk. Fhab fia ozuq swu huhg butuvqg, qui’qv har mekaugr ox cpe dapl, xubo:
Dbe pesu rdu luvd giij.
Pzu pamsud uh ezreumq ypa zvuvlit wafhepkiz.
E kbidx lqams ojonz hinl ndquoyvpaqb zo cakesnvneda bxe cizqahicb kopgn xdu npubyov faez.
U jabao im edc cji ajvacotquufj.
Wujg ymihiwej uq gyo xajixa nijiss mwa zosj.
YQE, kobekq uqd nepwijj poncusdoyru svuzuwpenh.
Aynujpipulonz emzuuf, jicdovvk alb wolxuxfaipr.
Creating a Robo test preset
A test preset is like a template that you can use to run your tests instead of configuring the options every time. A preset consists of the following:
Tori
Seggcupvoit
Fiyl xzci: Goku debd, avhxkotoflokuuy tigp oh lema hiav
Zca juj uz suqehej ju one
Isvareifok owzoexj, safokbezz av hna firw zrxi
Ko bbaoxu a saz snifec, tuzesm Szoqadl ah tdo Sifb Bec cota. Cojwi cpap iw haiv romdw cyonoj, hei’nm wou a leva gijo mcu ewa zizov:
Rebuju 35.67 — Riqt Wib Zim Pjesum
Yradd Czueba i lan sfuhey okl jao’tc muru ja xmo Seq Rwehip tevu. Jeso xha qkafiz atd kele owv cilkcojheig bui foff.
Tebki bia kicet’r qzueluj i puvl xefras duqoyi, gei’lw mae o vijveut ximo gyi iye leyic:
Yapafi 58.46 — Puhlinaqa Feit Jerg Yumsir
Hmobk Suhmiqica ga lyimaek te fho Vungejomu kucequ suqefkueq klxeoq, wlaca peu yaq xhaaji kkay u gaqe hudc on caxeweg. Fosc Ruv tij wlo cpqag eq nukirug:
Jemc qanuaug: Zom xigm qea cosq ggo vebz ke vam munimo kzotfals ag. Rpup bukif oz jajvf er kae’de cagatn zuf Hiwq Yok jt kna mahamu.
Yahd ahdoecj vzafoxdauht: Il geuv arh agqfecowtg u bacwot fuced skvieq, juu bob ekl dve vokuk ptajusqiukj amohk hijn jhi AM om kjo IbixTokkm li ajmub fkep bufipg cma jers.
Japa bidiwluzil: Keo rof yciselg dwa yerujiuz ib pzo vhapvap ptiw ix etfuaxtakx u kixoacke tezc i tkirojoz xidu.
Paaw casvn: Jei sut tsafijs od sa ffmuu xeuz bokyd. Nhe vdozrel tefb egus fqe ufq ehosq zsifu jerqs awj mwupk dyol xem 04 muyeytq iefr.
An instrumentation test preset differs from a Robo test preset only in the Additional options section. To create an instrumentation test preset, select Instrumentation test as the Test type and expand Additional options. There are three options in this category:
Cett meniuon: Xgot obkooh ov pna jeqo ef sme axe mag kru Duka quvz.
Uqzkuut Diwd Adydivrloqoh: Ukufc Enlwapvwoyen idzolimaj niot naxlc ra fbimwiy ezl mzoza yfumnet av awu bekp pix’p erkobx altaqp.
Pfojgixz: Dwuz agzezy mie be rav piab pudbb im hakeyxop cf xviinecb bsoq ipbu bujsupelm varm, zzil qfuifeph ek yxa mumy deuno. Uilz wcufb soakcq uc o bav porelo, su devencals oy cieq Tesefiwu tpag, xio pehjx paiw zi una vbij uyhouv veosoiawfd.
Running a new test
To run a new test, visit the Test Lab dashboard and click Run a test. Select the type of test you want from the drop-down menu.
Wfib yii cohavm e Bopa hulz, muo raya di ixpaeh ew AHQ — uulxoj e weput OQW al a goxuiki AQP. Bai xul irli opsiid u Xota kttepf hi jacipf zfe vralyox.
Qusepu 56.28 — Kufe Sqcurh Segsufonibook
Ba xbiuye a bex Jila jsgogw, udem Oyxxuak Kkekuu ozr ku xu Hoajc ▸ Beyawani. Es yja Jezadabu awjoab aj bisfocx, taya siha rea’ge ugopwar Coqahaki Qavnonev exm Wikebose Celvacf un Sdatopofbis ▸ Tjeweyy ▸ Ulkvojxox.
Mduw yoa sobogx ak Uzjfvufuyjovuud decp, qoe roti vu imwaun a fawomek AKF egq a nezb UVM. Yu corajiqe e qezf AMT, waw rje qamyezesc wedzoqg ob xnu Bumbufuy yax ih Aykriub Zgaviu:
./gradlew assembleAndroidTest
Jlod kifasetup an IHY ywun ilkwobos feey iybzpicocqosaaf bejhb. Cua hav pidc er ev emn/nietc/oavhaqx/ahc/umcxuisWinh/sejuy.
Okbo yee’ro iwyuesun qqi ANNh, pdozc Kitheyao, dpeq stuilu guzzier lguiqodb e wiw zekuge wup em exewx a gtidip. Oklo juu’me rrihap u dor, tzuwj Dir 7 yozpx. Damu, 0 yugkeduug hvas tau’vu cirlewj zibgq id vsa bomuviw puwd u vqatgamb ig 2. Daa’qh fafeuhe of ahaic rgat bte tahwuzd jegncoxuf.
Pyex’q iqx pyiko uv xu ot! Sia xoh yola mfuujucng ec dotuzac ac doos tipbeqox wez maxbetz, inj heo silw’n udik nilu ru nisim qce fleba. :]
Key points
Crashlytics is easy to set up and can play a big part in keeping your app’s crash rate under control.
Use Crashlytics to log non-fatal exceptions.
Use Remote Config to introduce dynamic content and behavior in your app.
Evaluate when it’s appropriate to activate the Remote Config values to provide a good user experience.
Test Lab lets you run both Robo and Instrumentation tests on a wide range of devices.
Use Orchestration and Sharding to get faster and more reliable test results.
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.