Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create multiple targets for Android project like Xcode Target

I worked with iPhone Xcode Traget to create multiple iPhone apps with single code base. My question, is it possible to create multiple targets for Android project. If yes, is it possible with Eclipse?

Edit:

Xcode Target: A single Projects can contain one or more targets, each of which produces one product (App). This has always only one Project in which we can select the specific target and run desired app

iPhone have only one Project for many products (App1, App2, App3 etc), Now can I have same as this, one Android Project and multiple products (App1, App2, App3 etc)

Thanks in advance

like image 904
Vinayak Bevinakatti Avatar asked Feb 02 '12 06:02

Vinayak Bevinakatti


People also ask

What is the difference between project and target in Xcode?

An project is a repository for all the files, resources, and information required to build one or more software products. A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace.

What does Xcode automatically create for each target when a new project is created?

Xcode will automatically create a new scheme for this target. To change the API endpoint based on the build target, first you'll need to set a custom flag. Based on this flag, your code can update the variables accordingly.

What is Android build target?

An integer designating the maximum API Level on which the application is designed to run. In Android 1.5, 1.6, 2.0, and 2.0. 1, the system checks the value of this attribute when installing an application and when revalidating the application after a system update.


2 Answers

A bit late, but for those who still looking for solution:

Gradle Build System uses a Build Variant and combination of product flavors to generate different apps with shared/common code base and resources.

As per Android Developer Reference Site:

The build system uses product flavors to create different product versions of your app. Each product version of your app can have different features or device requirements. The build system also uses build types to apply different build and packaging settings to each product version. Each product flavor and build type combination forms a build variant. The build system generates a different APK for each build variant of your app.

Now one can have two or more product flavors e.g (paid flavor, free/demo flavor) etc for one single project with same code base.

For more information See Build Variants & Product Flavors Doc

like image 103
Qasim Avatar answered Oct 20 '22 21:10

Qasim


After a wide research I realized Android Library Project will provide solution for my requirement

An Android library project is a development project that holds shared Android source code and resources. Other Android application projects can reference the library project and, at build time, include its compiled sources in their .apk files. Multiple application projects can reference the same library project and any single application project can reference multiple library projects.

Note: You need SDK Tools r14 or newer to use the new library project feature that generates each library project into its own JAR file. You can download the tools and platforms using the Android SDK and AVD Manager, as described in Adding SDK Components.

• If you have source code and resources that are common to multiple Android projects, you can move them to a library project so that it is easier to maintain across applications and versions. Here are some common scenarios in which you could make use of library projects:

• If you are developing multiple related applications that use some of the same components, you move the redundant components out of their respective application projects and create a single, reuseable set of the same components in a library project. If you are creating an application that exists in both free and paid versions. You move the part of the application that is common to both versions into a library project. The two dependent projects, with their different package names, will reference the library project and provide only the difference between the two application versions.

like image 40
Vinayak Bevinakatti Avatar answered Oct 20 '22 19:10

Vinayak Bevinakatti