Blog

I write code, this blog is a dream.

2013.06.28OpenFL AndroidManifest.xml and greater Android SDK version

Say you want to publish your android application but need to restrict it to some devices screen or need for any reason to have access to the AndroidManifest.xml.

First find the location of you openfl native library:

$ haxelib path openfl-native
-L openfl-native/1,0,1/ndll/
/Users/lbedubourg/Library/haxe3/openfl-native/1,0,1/
-D openfl-native

Then get the regular template and put it in your project:

$ mkdir -p templates/android
$ cp /Users/lbedubourg/Library/haxe3/openfl-native/1,0,1/templates/android/template/AndroidManifest.xml templates/android

And finally tell openfl to use this template version in your project.xml file:

<template
  path="templates/android/AndroidManifest.xml"
  rename="AndroidManifest.xml"
  if="android"
/>

Now you can edit your manifest to your taste.

What if you need some feature from a more recent Android SDK? We need to modify the hxcpp build script too:

$ cp /Users/lbedubourg/Library/haxe3/openfl-native/1,0,1/templates/android/template/build.xml templates/android

Edit templates/android/build.xml to change your target (that's the target value):

<property name="target" value="android-17"/>

Here I used the lastest API: 17 but you might want to use the 'android' tool of the Android SDK to install older APIs in the hope of supporting more devices.

You might also want to modify your AndroidManifest.xml file to reflect your change:

<uses-sdk android:minSdkVersion="17"/>

And finally tell openfl to use it in your project.xml:

<template path="templates/android/build.xml" rename="build.xml" if="android" />

I am sure the template node will prove pretty useful to hack things around and not only for android target!

See the useful openfl project.xml format documentation.