Skip to content

Instantly share code, notes, and snippets.

@ph0b
Created July 15, 2015 13:17
Show Gist options
  • Save ph0b/111122b0ab181d991620 to your computer and use it in GitHub Desktop.
Save ph0b/111122b0ab181d991620 to your computer and use it in GitHub Desktop.
ant rule to prefix APK version code depending on the native code of the APK being generated. useful for Visual Studio 2015 Android projects.
<?xml version="1.0" encoding="utf-8"?>
<project name="custom_rules">
<available file="libs/x86" property="x86Dir.exists"/>
<available file="libs/armeabi-v7a" property="armDir.exists"/>
<target name="-pre-build-x86" if="x86Dir.exists" unless="armDir.exists">
<echo>prefixing version code with 5 (for x86 ABI).</echo>
<replaceregexp file="AndroidManifest.xml" match="android:versionCode.*([0-9]+).*"
replace='android:versionCode="5\1"'/>
</target>
<target name="-pre-build-arm" if="armDir.exists" unless="x86Dir.exists">
<echo>prefixing version code with 3 (for armeabi-v7a ABI).</echo>
<replaceregexp file="AndroidManifest.xml" match="android:versionCode.*([0-9]+).*"
replace='android:versionCode="3\1"'/>
</target>
<target name="-pre-build" depends="-pre-build-x86,-pre-build-arm" />
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment