【问题标题】:Multiple android project with one core library and multiple localisation一个核心库和多个本地化的多个android项目
【发布时间】:2013-01-17 16:49:00
【问题描述】:

我基于同一个核心库(包含整个 UI 和所有业务逻辑)为多个客户开发软件。如果一切都很简单,我会在启动项目时引用该库,并使用变量修改核心库中的不同标签。

例如:

Core library : com.test.core

package (and apk) 1 : com.test.core.customer1

apk 2 : com.test.core.customer2

最终结果:对起始包(标签等)的矿石包进行了一些修改。

我尝试更改启动包上的语言(例如 package1 = fr, package2 = es):Launch an android application with different resource file

但缺点很简单:如果我使用一些 Android 功能,比如复制/粘贴,就会显示错误的语言。

一个想法是用ant(或类似的东西)配置eclipse,以便在我编译customer1或customer2时在编译时动态修改values/strings.xml包,但我不知道该怎么做.

我将 Eclipse Juno 与使用 android >= 3.2 的应用程序一起使用。

问候

【问题讨论】:

    标签: java android eclipse ant


    【解决方案1】:

    这种情况可以用ant解决。

    我下载了ant-contrib,放到C:\ant-contrib\ant-contrib-1.0b3.jar

    在项目中我创建了文件specific/lm/strings.xml

    我创建了 custom_rules.xml 文件并使用 ant 启动它。

    它使用应该设置为 true 的 lm 属性。你也可以使用目标lm

    <?xml version="1.0" encoding="UTF-8"?>
    <project
        name="com.test"
        default="help" >
    
        <target name="lm">
            <property name="lm" value="true"/>
        </target>
    
        <taskdef resource="net/sf/antcontrib/antcontrib.properties" >
            <classpath>
                <pathelement location="C:/ant-contrib/ant-contrib-1.0b3.jar" />
            </classpath>
        </taskdef>
    
        <if>
            <equals
                arg1="${lm}"
                arg2="true" />
            <then>
                <property name="startproject" value="specific/lm"/>
                <echo message="Build spécial LM / Projet : ${startproject}" />
            </then>
        </if>
    
        <copy file="${startproject}/strings.xml"
            tofile="res/values/strings.xml"
            overwrite="true" />
    </project>
    

    你也可以使用maven Skinning Android app with Maven build profiles

    【讨论】:

      猜你喜欢
      • 2012-04-07
      • 2017-01-26
      • 2014-07-23
      • 2013-04-01
      • 2014-07-31
      • 1970-01-01
      • 2011-03-11
      • 1970-01-01
      相关资源
      最近更新 更多