Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable package name with Maven Android Plugin

Tags:

android

maven

adt

I'm using the Maven Android Plugin to build my application.

Actually, I'm building 3 "branded" versions of the same app (the app icon, colors, etc... change, but not the features). I'm aware that I need to use a different package name for each application, for them to be considered as different.

So far I have managed to have "dynamic" values, using Maven filters in strings.xml :

<string name="app_name">${app_name}</string>
<string name="widget_name">${widget_name}</string>
<string name="app_icon">${app_icon}</string>

The problem is that this does not work for the package name ! If I do :

<manifest package="${foo.bar}">

ADT (well, the XML validator actually) complains saying attribute package has invalid character '$'

I can't find any workaround for this... Is there a way to tell ADT to launch the Maven resources filtering or something like that ?

like image 662
mexique1 Avatar asked Sep 29 '11 11:09

mexique1


People also ask

What is Android app package name?

The package name of an Android app uniquely identifies your app on the device, in Google Play Store, and in supported third-party Android stores.

How do I find my Android package name?

One method to look up an app's package name is to find the app in the Google Play app store using a web browser. The package name will be listed at the end of the URL after the '? id='.


1 Answers

After further research, it appears to be fairly easy !

You just need to add <renameManifestPackage> in the configuration of the Maven Android Plugin. Seems to work starting at version > 2.9.0 :

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>maven-android-plugin</artifactId>
    <version>2.9.0-beta-5</version>
    <configuration>
        ...
        <renameManifestPackage>${manifest_package}</renameManifestPackage>
    </configuration>
</plugin>
like image 153
mexique1 Avatar answered Sep 28 '22 12:09

mexique1