问题
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 ?
回答1:
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>
来源:https://stackoverflow.com/questions/7596771/variable-package-name-with-maven-android-plugin