Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Multiple .apk file from single code base

Tags:

android

apk

I had developed 3 applications in android where the major functionalities are the same but the UI looks different. Images and the background color of the screens are different.

NOw, i want to create a single code base from which i can generate multiple .apk files for the 3 apps.

I tried creating 3 different packages for src folder for the 3 apps. But i dont know how to set the res folder for these apps.

Need pointers on creating a single code base from which we can generate multiple .apk files which includes only the respective src and res folders.

like image 883
Prem Avatar asked Nov 15 '11 12:11

Prem


People also ask

How you will create generate multiple APK in a package?

To configure your build for multiple APKs, add a splits block to your module-level build. gradle file. Within the splits block, provide a density block that specifies how Gradle should generate per-density APKs, or an abi block that specifies how Gradle should generate per-ABI APKs.

What is split configuration APK?

Apk splits allow app developers to divide (split) their apks across device densities and Application Binary Interfaces (ABIs). These separate apks are uploaded to Google play store and users only get to download the right and optimized apks for their device.

What is multi APK?

Multiple APKs is a feature on Google Play that allows developers to upload multiple APKs based on pixel density, locale, ABI, API levels, etc. Android Developers documentation lists many rules that developers need to address before publishing APKs on Google Play.

Is it possible to create an app for more than one version of Android?

You can use it to create two versions of an app with separate data files, so both versions run independently. It provides excellent privacy features to protect your data, and you can keep the cloned apps in a secret space with a security lock using the incognito installation.


2 Answers

  • Use an Android Library Project that contains all your common code.
  • Create separate Android projects that reference the Library Project (you will need to copy your Manifest into each of these and make sure all components are declared with their full Java package name).
  • Put any resources specific to each app (drawables, colors etc) into the individual project resource folders and they will override similarly named resources in the library project at build time.
like image 59
Jeff Gilfelt Avatar answered Oct 13 '22 00:10

Jeff Gilfelt


i think the best option is to use ant, you'll need to add an ant target for each build and change the resource folder. if you use the generated build.xml, the res folder is defined like this <property name="resource.absolute.dir" location="res" /> so you'll want to override that

like image 24
tbg Avatar answered Oct 13 '22 02:10

tbg