Mart Roosmaa
Mart Roosmaa

Reputation: 953

Passing custom arguments to aapt in Eclipse

Is it possible to tell Eclipse to use some extra arguments for aapt (-0 in specific)?

I have been looking for past couple of hours and the best hack I came up with was to create a wrapper for the aapt tool to inject the argument to the command line. The trouble with this approach is that whenever I should lose that wrapper, then I'll be quietly introducing a bug into my application.

Upvotes: 1

Views: 2342

Answers (2)

JohnnyLambada
JohnnyLambada

Reputation: 12826

Thank you Christopher for your answer. Here is the aapt wrapper script I built in python for my purposes in case anyone needs it:

#!/usr/bin/env python
KEY=r'name-of-your-directory'
DIR='/../../path/to/your/include/res/'

import os
import re
import sys

mydir = os.path.dirname(os.path.realpath(__file__))
real_aapt = "%s/%s" % (mydir,"aapt-real")
#args = sys.argv[1:]
args = sys.argv

found=False
nextisdir=False
newargs=[]
for arg in args:
    if re.search(KEY,arg):
        found=True
    if nextisdir:
        nextisdir=False
        newargs.append("--auto-add-overlay")
        newargs.append("-S")
        newargs.append(arg+DIR)
    if found and arg == '-S':
        nextisdir=True

os.execv(real_aapt,args+newargs)

Upvotes: 1

Christopher Orr
Christopher Orr

Reputation: 111623

I don't think it is possible without some sort of wrapper script as you mention.

Alternatively, you could use an Android ant script to build the release version of your application, as that lets you easily override the command line parameters used. It also helps you build things independently of the Eclipse plugin which is useful should you get into continuous integration.

Hopefully you wouldn't be quietly introducing a bug anyway due to at least smoke testing your app before release.

Upvotes: 1

Related Questions