Variable package name with Maven Android Plugin

℡╲_俬逩灬. 提交于 2020-01-10 02:36:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!