are correct by looking at the build output - assume the metadata
is correct. This takes away a useful level of sanity checking, and
should only be used if the values can't be extracted.
+ fixtrans=yes Modifies any instances of string resources that use multiple
+ formatting arguments, but don't use positional notation. For
+ example, "Hello %s, %d" becomes "Hello %1$s, %2$d". Newer versions
+ of the Android platform tools enforce this sensible standard. If you
+ get error messages relating to that, you need to enable this.
Another example, using extra parameters:
if thisbuild.has_key('rm'):
os.remove(os.path.join(build_dir, thisbuild['rm']))
+ # Fix translation files if necessary...
+ if thisbuild.has_key('fixtrans') and thisbuild['fixtrans'] == 'yes':
+ for root, dirs, files in os.walk(os.path.join(root_dir,'res')):
+ for filename in files:
+ if filename.endswith('.xml'):
+ f = open(os.path.join(root, filename))
+ changed = False
+ outlines = []
+ for line in f:
+ num = 1
+ index = 0
+ oldline = line
+ while True:
+ index = line.find("%", index)
+ if index == -1:
+ break
+ next = line[index+1:index+2]
+ if next == "s" or next == "d":
+ line = (line[:index+1] +
+ str(num) + "$" +
+ line[index+1:])
+ num += 1
+ index += 3
+ else:
+ index += 1
+ # We only want to insert the positional arguments
+ # when there is more than one argument...
+ if oldline != line:
+ if num > 2:
+ changed = True
+ else:
+ line = oldline
+ outlines.append(line)
+ f.close()
+ if changed:
+ f = open(os.path.join(root, filename), 'w')
+ f.writelines(outlines)
+ f.close()
+
# Run a pre-build command if one is required...
if thisbuild.has_key('prebuild'):
if subprocess.call(thisbuild['prebuild'],
vercode = re.match(pat, line).group(1)
pat = re.compile(".*versionName='([^']*)'.*")
version = re.match(pat, line).group(1)
- if version == None or versioncode == None:
+ if version == None or vercode == None:
print "Could not find version information in build in output"
sys.exit(1)