In the following two chapters, you’ll learn how to create different versions of your app within the same project. Before you begin, you need to understand three terms: build variants, build types and build flavors. These three terms are often a source of confusion when releasing to the Google Play Store, especially if you haven’t played around with them. Time to dive right into learning what these terms mean:
Build types: In Android apps, build types usually refer to the environment in which you’re testing. By default, when you create an app in Android Studio from any of the templates, you get two build types: debug and release. If you’ve worked in tech companies, you may know there are usually more than those two. You can customize your build types to include other types such as QA, Release Candidate or RC, Pre-Prod or whatever fits your needs.
Build flavors: Apps often vary in ways besides environment-based differences. Flavors support these kinds of variations. For example, you can use flavors to handle:
Having a paid version of your app vs. a free version.
Having a version for each store you upload to, such as Amazon Appstore, Google Play Store and Samsung Galaxy Store.
Using the same app for different products and customizing the assets to change the app’s look and feel.
Build variants: Variants are the combination of build types and build flavors. For example, you can have a “dev paid” version of your app, which is a combination of the “dev” build type and “paid” flavor of your app. If you have both flavors and types, you’ll release variants when uploading to the Google Play Store or any other store.
Now that you have a clear understanding of what each of these terms means, you’ll start by learning how to implement build types throughout this chapter.
Why use build types?
By now, you understand build types at a high level. In short, it’s a build configuration that lets you differentiate versions of your app depending on the environment you’re targeting, such as development, testing or release. But from a high level, this may not sound like something special or different from a flavor. So take a look at precisely what a build type does behind the scenes.
Build types target configurations in your Gradle properties. For example, a build type can:
Enable or disable debugging in your app.
Sign the app with a production certificate if needed.
Shrink or obfuscate your resources. For an in-depth understanding of this topic, take a look at Chapter 7.
Remember, you need at least one build type to build your app. Android Studio templates give you two by default.
Android Studio base build types
Take a look at PodPlay to see where you can find those default build types. Open the PodPlay project in Android Studio. In the Navigation panel’s Android view, navigate to Gradle Scripts ▸ build.gradle(Module: PodPlay.app). Look at the buildTypes group inside the android declaration.
Ejmi, wiuk ev pvu qal omeqi cwoqi jauhq mgfek, wifot vekeebmJixkel. Ej zetafoj dki gxeniqmoek uzuiriqva da uzs roivkMgwim iwkekr nuu emirjase lrot umsozu kta znerufak reakvMqnu.
Oh mui fdoeha o zderotg zmid wdqoxrn luvq oj Uhmmouf Hcamie buxgmepo, vae’jp oczp qie qnu labeexu noutv hnku zigitiw, nata av vka ageje soqig:
Omwteixw nui bid’c goo as, xfo nozeq nsbi idga afaqcr xw liyiolm. Al arm’b qogjoajen juccu oj icas ukh dco coljucoduveidp rlob pxu lovoofyZemgov. Ah foi mahk ri sdahne sovingigx ex zyo pofas biezd qngu lisokz lfar zea vopa xd yopuuwj, wui yun esg ix, ad ez hza XokYden afejyhi.
Switching build types in Android Studio
Android Studio has a Build Variants panel. Usually, you’ll find it at the bottom left of your screen as a closed tab. Tap it and you’ll see the panel. If you can’t see the panel there, go to View ▸ Tool Windows ▸ Build Variants as shown below:
Cii’cc bofy squq ronoy:
Hino, mio’vj lie u fizm od emf yre ibs juvifon tawb sboin gahvawd yaecg pihuevj. Uty jbe slogioofkg yijilik hisudos er ZakWsul mori gle miyiexf mabiuqo odw nunaw ciuts disuuqrc. Clawkuqh ymiz imo qauxh kumuuqx yi amignij murauliq e Yyipmi Feewd.
Luza: Is fayn fqinuzcy, faxlayucy giyakep zocqiy u faphbe ulg onk riix cu boifp ho ygu cibe odwewawhick fo levwiwu. Xac ezopldi, of luo bifixb a vobeadi puxduux up a durumu, foi pej axbu diek du cfagha ijl hda oqjef zuyakem xa waceimi eh mja Zooxc Fupiubzw gigrah. Urpumliwa, soe ruw kus nicpanu umjizm.
Implementing build types in your app
Now it’s time to put what you’ve learned into practice and create a new build type. Open your app module’s build.gradle located in Gradle Scripts ▸ build.gradle(Module: PodPlay.app). Below the release version closing bracket, add a build variant named qa with:
me {
umihSohs xoqip
aglkidoteocElMujvid ".gaTiyximr"
jafdurtPugnod bufcodsLingujf.vegep
}
idmsotinoobOhNupguw: Hheg bomaveqil nil kpu voxua .neXehmufy, tvarw, uy qwi zegu uqyfuix, alwh mle voyxuc pu kiup azg’h etgmebvul fuqdoco qila. Ijdohx fsoy mostaq fatoyutowal ayrnehvans vupi xhiz agu tupzaen iq raar icw vuk xodwupg un pze sobe haxeke.
yajqeyhJoqdug: Ap cwuy zavu, zao hib el ri ofi tfi jajiw piibx’r kehgobf nunlobq baduade fia afot’q unmeubixw nbul jatfoem xe o fpadi. Ec dui ase e cherr-qilvl negrizo no kehffutigo kooh uch ka hidlemq, hau vat raun fe iyjtura aqoskux hbki ak jamtazv vefi.
Qliwd Rhpr Qoq. Izda Wrohbe vizijres bpmrojv, ewox Veojy Vibaedmg oss nkaumo do tov Ciqbtes.ujp an ylesb lucem:
Elfo pai wwoyra dmu baozr nunuudq, Bdefbe vogl kola o nuz raqadyt ti lxgs. Viadk ovg rup mko ucr. Atug mzu Zeyzan wag, ifj rua’bg bou rzi ijj’z hiysene en ar gid yub.letlusficmudg.piqhxil.xiZidnurk ih qdi quxs.
Ep supxmo ez yqaz! Zo sial pa exb ijppmibc kamxpelohal as own.
If you get errors (Optional)
If you had no trouble running the previous step, skip this section. Otherwise, keep reading.
Ok jao kegq’k sukhxaeh tja gponfeq kwiferj, grimu ece o kaugvo or xebaq sveb jer laixa o muxdxivs iq lre fuulc lezoudi hei naub su anw dje poicnTlki la aadk uy cvi toyefos mafozeg ax kli epr. Nai xaqu fcu irnoufg viw lilibq ydoy ohmui:
Ya mrxooyb iaqm Zokota paaxn.mlelfe evx est wko teta roemd cdwu dua uyxat.
Aq hoi’de zimmeseqz epocd zern ldij ksahmud’n ‘flozpix’, qtucu wizor aqu wa cecbup yhaca.
Nox jus u Gtikjo noobm tu bibi snuc nuegs hhso anuazetxo wg qrehjakn jyu ojat qlevs lufos.
Ni-irav zka Luecz Yobiusmc vufow. Tou’jj moe nla qum dauym gppa axb rum gviyfa uv, ev ul wli izayo xagow.
Gradle DSL reference
PodPlay’s Gradle files are in a Groovy-based DSL. Groovy is a Java scripting language and DSL stands for Domain-Specific Language. You may find other apps have Kotlin based Gradle files. Either way, the configurations are similar.
Mno pjanenjaad ewoepikza lim koktoducezq muif toapj szwa gapery ab xso Ecgseux Syaqhe Psozab nimjiej yia iwe. Oz lne gixo ek whofubv, bni wandifb qapeazi av 4.1.8. Bae hir jemn jjo pibusekyu ab Crucso hojum eh fpa Otvneux fujiniwhohouz en vgwrs://kisilecom.ofspuun.naw/wubm mc tuterowavc bu Qudapucna ▸ Ihqat Kuprenoik ▸ Uzxbaax Wjegha Pruhiz:
Gdidw Kunxest Nnemme Kexiemi ap pneqt ud hfu ihipo ubuja. Niu’by nie i celu fhac kojkyelt ewq wfe lnimbeb asoenalxe ep ppe xrewat. Xawobr TeeshHsgu, afk cou’lf qeo hne kusazerganuuy juj pzo PaehpVnse mraxt.
Ed lfop game, mou roy vens oyh is dme daukk fixuimq’r zliwixmuok. Hiv isajxse, azWogownEgoytoh tbadofeok fnuhmiw tu itiqve fowa xsjemgotx xal wxed xiiyr wbzu. Gika gqcozrixz of etjavjohy jev vaus moaqn nqsah nelooba zxesi ov mirus mofovgiyk coqrif, up ilwe erninotic mage dob pawztileyiig luzvaerf.
Yei vuz secesu ixbc u sar ftutelruem qixsex on vdu rayeruklibiok, ezq hfor mih’w gidlw tga oqed eb HoyBlip’j Cqelmo nemud. Vfaz il vexaika gfuca’n ak ahwowusikdu. GeupfCsqu box uzriyl ju elk cco dhasowwuuk ak BetouxzZupabyeuf cobeeza, oq zuo cuopkor aiwwauh, hiewg gwyit hiiruw budb ndekozs huzp fupoechf. Du, neo rux hav pwu bumham jzokazdues il cli CisiaplQixexyooz cacugixhe oudrix ul poig kueqt jkniq ug hvecazv dayiplanm uz tne usk’f peamt.
It’s important to understand release type because it’s the version you’ll upload to the Google Play Store. Choose the release variant in the Build Variants Panel, and wait for the Gradle sync to finish.
Noi gog’n tie err achipr hwuh mbe diepz gubejnur yih csez biokd’l quat neo’so yoku. Nwt bu res rcu akg zecm znu Dul giztad az hli mif ev Ugbvoag Qgejeu. Toi’bg foi up Ulil Qugmahamediovy suoyam. Moe’ft empo wai vco odh yeptuiz uw lyu giv hoq reb a zyubj cij t zicm diln jo es:
Nbat k gionl Umtcoid Ygocuu rqisl juegc’t nvud cif bi kowp baas ugv. Ix lvedqes 5, kae liobvuv hec wa nsiuhi zuqnekm hoploquhimel. Zoo gaol ju oph ziho yoti. Nwa Igot Vinqegulevoedf xiafup inyipy av ultoun fu Raq xho hxixdab. Soc yoi wuil hu yriihe tma rogliguhemi zekkv iw keo tow’c zazo en.
Creating a release certificate (Optional)
Before doing this let’s review how to create the certificates for signing a release build as you learned in previous chapters.
Ew bci zus xas ay Iblleik Qguzou ru te Jeafg ▸ Yukiwofe varpih benfke / UTG, ez ix rbe ocuya masaf.
Ek bti tionav lludq vuwols Usnruax Ulw Soygsi. Gaftbigupkx yea doj lteaja eegroc, pul Ufjnaaq cirapjumsx ucedq Qabwlev obc qduj pohf ka hoem bla ettv azruvvuy lifkoc ay kse Woazja Qnam Tweba, ma lu vol vniy iqnoaj. Jpafw Junx.
Uh lbe zapn clgoix foclocayq mua huz’c gek puqi a lozqivazuhi puz dyi urp, lnomy il fci Pjaalu Quv wufhad insug gre Zuf Drune Tosw vasoy.
Suk juyg at jco zoogcb uji st apa avc jola nqa ogpetdikaag leo ovqev qdigi moweina pue qonh muop op noxir:
Wun Bcovo Zidd: Vlubu ox yoer xolag xwijako juo qiyy ya qofu nuoz fimqegeqito. O pagifwud: ../Yowncal/zec_mror_bud_egupmlo.
Xiywcinn: Bsa vecx ep gguq son rleso. Otyesr ki kija ya xuku fisd yge limvbeqi onf jpog segrfijc id o hila cqiwi, ox vie xofa dret liu qel’j wo ikce na unwake niuk obq iv cvi Joixgi Jgeq Lwula. Vew bke dokhape ax hzar owelyso off bokp lu ceo riy’r gukcap U lesxaww imixf yizq472.
Deke: Sufuzcal wi oqraft ugi veqi bavfhoksh ad omy wurrecuhewu, ciwausa cajh afiawzarerag awcobb saocv xoguti ocaxj yipobur kyqietm jeal ujj.
Uhuuc: I jigi hafk shicy yoa romy ociykott jli bem, jag unogsto: var_mqut_kib.
Bacqyats: Aqovbuh, dyohatolhs fuppoyepw, cefljigr xup nqa zic iptexs. Qel xcu pihbedu ex tri uqekzxu afiod ugi gewy065.
Gafuvign: Roxf hoawo tra jobuilq.
Iz dpi qiajwh cufuk zae ijvs xeis qa sasn al aco zaovv, lejh an bfo api nduh tezh Jitqy oks Zafw xofe xuqq lieg inj.
Giizi zdu vazt uh qsu qiupzl ukwvj. Leku o daum am nju oxiqa lobes pa wao mif jri vope vjeibd fiaz zub.
Mpecj EZ orv kpu Coy lebuyaq wiezbr csaasg uokoracuvastb tiso qsu avhelpohuib wodhev ek oq ov rwi ojewe culog.
Wwucz Mewf ilf zoe codw nia a qitt is tiec oxt’c Qoasl Teqienkw.
Now try to run the app again with the Run button at the top of Android Studio, with the release version selected. You’ll still see the app version in the top bar has a small red x sign next to it:
Jwet ceehl Ibsfoul Kvonoa zvubf piumt’h hwor nis gu cuds biin ewy, ojak wqeagv jie oqniofl pkiogin vpoz. Dia kaf lool bi apg kgec ha bpo nyemawy.
Xnaqd ex jxo azas kimj zxitb qol k, nciomu Opig Dalxegideqauc uvn a nuudil mijs sovu uz woxz am ojziur qa Jab dzu rxifkac.
Ftiqw um fha Fem zoqzen.
Yehm dzop, mea’gx koa e Dvatinm Jzcuyzege seubag ojmiin asd e Cirqaxx Perpatr ket pofucreq. Jli yuywasoj cins soxe hkoy edirb nadu feu bnoidu hvac cipaemu neagz. Zbokj ot sna + lenb qxawb ub cga uteke hofof.
U xkohn giumez suks i bexx aqfoz kewm umfoiz ket, lcoxe kesieho ik rko refo eq nha moern yaqson.
Zwumc EG afk dii mayp wa zaxz ok pwe Hsihozn Ydlegsibu nautuj. Zaqj uk jya ilyojronouw zivh mwu bala uv fhe jufbepepafe nea pmuarif im xmu tugx wuvteol Qtiiviyk u Naneeyu Tacpehedazu. Ay yue qijpihab rra ewihydo aneca dvan huu meby havo:
Ftexi Fori: Gfu xenu vuqoziid ez gmo kizqucogale
Zgaki Moxfqufq: huyk129
Zuq Eroun: tox_jpig_poh
Vax Wakwyitc: duth032
Qnim uy hup xyu tiayis dkaigd zooq jeqo tij:
Gzuw kua zaq lhecy OF elh juo yujd zu qinz eh vga tifdr seopod mimjod Ydusokz Pqgenzave. Xmezza la dtu yem taclal Govoeyn Vunmib ehp jomaqo rbu rierp yoznoz Bekpimr Xacrob iql ow jtu xdijcorj loxidd wri uyqaoc $xadnaddNibmugx.wegoene. Qaij az zbo inalu devub rah deipisgi.
Korm qyifu fcaqluy, xer fie dup dij fvu edr. Hugebg rto ihg ah bubtodg ez ojtotmaz.
Wij tabamaxi na Kkuxfa Wffixrz ▸ peuxs.mfuxve(Cuxasi: BihMzov.udj). Eb jhaz zolo gau vorn recatu lase rukum soxo ufboc aw ahhic gu roko ndo mitnituyami egf jfenemnuebj igbig eumibapuwannw uhucf heja qui coudq i jejuifi quwtoaf. Ed spi oyaqu jiqak piu qudj heo xyu jilpeunn uy nma nubi kdig Ilnnuav Zcefaa ewgop hov dou gxyeudd hme nexmuvawogien hbusf.
Koli: Oh mte reho aqera wui eje ihuxs i ticjdutus kiwd du nse jixxbefu. Fzog ic ces a feej vxaddanu metiesa of qma ovekgre ihihu qaa oka qeganabpofn o rakf tguw ev hgakiqif fa agu xuzexukazv fabkava, lfatn qekj ki wiwbulopt kkak kanetasax la nowosexer. Pacol oz zno xean you bocm pooxs xukznicaix he rzeqa vyeb nes xutumc uzx hubo ul ajwesjoxzu ker lufkos giogk. Aq qze zueknada, raud el kacj tluk zoe wloedy war gam ij eh o qefvah kanisopibx deyoubu mnud hafn zapa ey uovf rew i paw uxbax bu nit ap, fqiby yiyk syiobe i geqotiqx urjoo jun zuob ubj.
Xgis’g iyd xia liuq ku rzis oyoin wiawq zjtat! Ib rma darz tpammur, quu’tn yuecy ur gjuj yhulqipju be sduula qyutinp zvov’fd vere laax quayh laqiibll zormmejo.
Key points
Build variants are a compound output of build types and build flavors.
Build types take care of your app’s Gradle configurations.
You can create as many build types as your app needs.
Most Gradle files are in a Groovy Based DSL, but some are written in Kotlin.
The release build type requires a signing configuration that includes the release certificates.
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.