[URGENT] Target android mobile and tablet with different assets

My game is built with conditional flags:

#if mobile


#elseif tablet



I don’t want to package all assets for both in one APK. I want the best quality for tablets, but also cater for mobile with lower quality & support for older versions (as they have texture limit of 1024).

Currently I compile my APK with just tablet assets. The spritesheets are around 1024x2048 this would obviously break on some old devices.

I am concerned at this point for compatibility.


You could do something like this in your project.xml:

<assets path="assets/mobile" rename="assets" if="mobile" />
<assets path="assets/tablet" rename="assets" if="tablet" />
1 Like

If that works I will be so happy. How does OpenFL work behind the scenes with these conditionals?

#mobile & #tablet

Does it adjust the Android manifest as required? If so that would be so good. For example setting the screen sizes based on these conditions?

if screen size x-small and small = if #mobile
if screen size normal, large = if #tablet

If an asset path isn’t included it won’t be in the apk.

That’s a compile time feature,
and my example would allow you to make two apk.

You can overwrite the manifest, and you could provide two versions and select the correct one with an if="flag".

I have been reading it is a bad idea to have multiple APK. I need to use one APK and serve different assets. This is what I don’t know how to do.

In that case you wont have “I don’t want to package all assets for both in one APK.”.

And openfl doesn’t have anything I know of to do that, you’ll have to figure out if it’s a mobile or tablet and do lots of if (mobile) { } else { }

That’s such a shame. So I either have to settle for mobile assets even for tablets (that will look awful) or use tablet assets and run the risk of assets not being compatible for texture sizes…

I do not plan on doing if conditions at this stage, its too late.

No, but you’ll have to pack both and load with something like this:

function myGetBitmapData (name:String) {
  if (mobile) {
    return Assets.getBitmapData("assets/mobile/" + name);
  } else {
    return Assets.getBitmapData("assets/tablet/" + name);

EDIT: well in that case yeah it’s that or several apk.

Or use Global inlined constant

#if mobile
public static var ASSETS_PATH:String = "assets/mobile/";
public static var ASSETS_PATH:String = "assets/tablet/";

Assets.getBitmapData(ASSETS_PATH + name);
1 Like