Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

android - How to quickly build 20+ versions of an app (with slight changes in each + different package)?

We are developing an Android app that will target different markets (countries).

The scope of this question is to answer 2 things:

  1. How to easily configure and switch a "global" parameter (e.g. the country which this "variant" of this app will target) within the app that will be used across the whole code base, e.g. a backend API endpoint. In other words, there are 20+ backend APIs depending on the variant being released.
  2. How to easily build these 20+ different apps, changing the package name for each and taking into account the unique global parameter above while building each.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

How to easily configure and switch a "global" parameter (e.g. the country which this "variant" of this app will target) within the app that will be used across the whole code base, e.g. a backend API endpoint. In other words, there are 20+ backend APIs depending on the variant being released.

Set up a product flavor per country. Use buildConfigField to add a field (or fields) to BuildConfig with the details of your backend endpoint.

How to easily build these 20+ different apps, changing the package name for each and taking into account the unique global parameter above while building each.

Run gradle assembleRelease to assemble all 20+ APKs. Or, run gradle assembleFlavorRelease to assemble the one APK with the flavor named flavor.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...