Related from the SwiftKey devs:
http://www.swiftkey.net/building-apks-with-different-features-from-a-single-source

For my setup I use ant to do release builds, eclipse to do debug
builds. I build for three markets (Google, Amazon, and direct-purchase/
beta). Each has it's own requirements (copy protection, updates, links
to other apps). I use a custom build.xml, it uses <replace> to switch
a static final int constant for what market I'm compiling against,
this handles all java "preprocessor" needs as java doesn't compile
dead code. I also use gcc's preprocessor on AndroidManifest.xml to
turn off permissions I don't need (And Eclipse builds just have all
permissions, which is fine). It's a bit limited and not perfect, but
it does the job and didn't cost much time to setup.

Here's the key parts of it, however these are for ADT13, haven't tried
to do an ant build with ADT14 yet.

Disclaimer, I don't know ant so I might be doing things awkwardly.
This is by no means a packaged solution, but an idea/example for you
to build your own system with.

Basically:
AndroidManifest.xml:
  <!--
#ifdef LICENSING_MARKET
    -->
    <uses-permission android:name="com.android.vending.CHECK_LICENSE" /
>
    <!--
#endif
    -->

MarketHandler:
    public static final int NO_LICENSING = 0;
    public static final int GOOGLE = 1;
    public static final int AMAZON = 2;
    public static final int DIRECT = 3;

    public static final int USE_MARKET = /* @MARKET_START@ */ DIRECT /
* @MARKET_END@ */;


And:
 <target name="market" >
        <antcall target="marketreplace">
            <param name="marketparam" value="GOOGLE" />
        </antcall>
        <property name="preprocessor.args" value="-DLICENSING_MARKET" /
>
        <property name="out.myrelease.file.name"
                 value="${ant.project.name}-market.apk" />
        <antcall target="myrelease" />
    </target>

    <target name="marketreplace">
        <exec vmlauncher="false" executable="sh">
            <arg value="-c" />
            <arg value="perl -e 's!(\@MARKET_START\@ \*/).*?(/\*
\@MARKET_END\@)!$1 ${marketparam} $2!g' -pi src/com/teslacoilsw/
tesladirect/MarketHandler.java" />
        </exec>


 <target name="-package-resources">

        <echo>Preprocessing AndroidManifest.xml</echo>
        <echo>gcc -E -x c -P -C ${preprocessor.args}
AndroidManifest.xml</echo>
        <exec vmlauncher="false" executable="sh">
            <arg value="-c" />
            <arg value="gcc -E -x c -P -C ${preprocessor.args}
AndroidManifest.xml | sed -e '/^\s*$/d' > gen/AndroidManifest.xml" />
        </exec>
        ...

On Oct 19, 11:51 am, sblantipodi <perini.dav...@dpsoftware.org> wrote:
> for people who posted that links, have you tryed to preprocess using
> android?
> does it works? I'm under netbeans and it doesn't work.
> Are you sure that it workd in eclipse?
>
> On Oct 19, 6:45 pm, Justin Anderson <magouyaw...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hey guess what? I found both of those with a simple google search...
>
> > Thanks,
> > Justin Anderson
> > MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
> > On Wed, Oct 19, 2011 at 10:44 AM, Justin Anderson 
> > <magouyaw...@gmail.com>wrote:
>
> > >http://boldinventions.com/index.php?option=com_content&view=article&i...
>
> > > Thanks,
> > > Justin Anderson
> > > MagouyaWare Developer
> > >http://sites.google.com/site/magouyaware
>
> > > On Wed, Oct 19, 2011 at 10:43 AM, Nikolay Elenkov <
> > > nikolay.elen...@gmail.com> wrote:
>
> > >> On Thu, Oct 20, 2011 at 1:38 AM, sblantipodi
> > >> <perini.dav...@dpsoftware.org> wrote:
> > >> > How can we live in a world with thousands of devices and dozens of
> > >> > market without preprocessor?
>
> > >> Learn to use resources, and ditch your C mentality.
>
> > >> Really, this has little to do with Android -- Java has no
> > >> preprocessor, and that's that. If you really think you
> > >> need one, use gcc (it is doable). Or some Ant/Maven plugin
> > >> that does string replacement before compiling.
>
> > >> --
> > >> You received this message because you are subscribed to the Google
> > >> Groups "Android Developers" group.
> > >> To post to this group, send email to android-developers@googlegroups.com
> > >> To unsubscribe from this group, send email to
> > >> android-developers+unsubscr...@googlegroups.com
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to