2

I develop a software for multiple customers based on the same core library (which contains the whole UI and all the business logic). If everything was simple, I would reference that library from starting projects and modify the different label in the core library with a variable.

For example :

Core library : com.test.core

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

apk 2 : com.test.core.customer2

Final result : some modification in the ore package depanding of the starting package (labels etc.).

I tryied to change the language on the starting package (for example package1 = fr, package2 = es) : Launch an android application with different resource file

But the drawback is really simple : if I use some Android features, like copy/paste, the wrong language will be showed.

An idea would be to configure eclipse with ant (or something like this) to modify at the compile time on the fly the values/strings.xml package when I compile customer1 or customer2 but I don't know how to do this.

I use Eclipse Juno with applications using android >= 3.2.

Regards

Community
  • 1
  • 1
P. Sohm
  • 2,842
  • 2
  • 44
  • 77

1 Answers1

1

This case can be resolved with ant.

I downloaded ant-contrib and put it on C:\ant-contrib\ant-contrib-1.0b3.jar

In the project I created the file specific/lm/strings.xml.

I created the custom_rules.xml file and launch it with ant.

It use the lm property which should be set to true. You can also use the target 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>

you can also use maven Skinning Android app with Maven build profiles

Community
  • 1
  • 1
P. Sohm
  • 2,842
  • 2
  • 44
  • 77