Badly formed android platform error

Hi OFL community :waving_hand:
This is the first time I try to test/compile for Android with openfl test android and I get an error I can’t get rid of: Badly formed android PLATFORM "21" - should be like android-123
My setup:

  • M2 Mac - Mac OS 26.1
  • Android SDK 11.0 (API level 30)
  • Android NDK 21.4.7075529
  • Java JDK 25 LTS from Adoptium

Thanks for your help.

1 Like

The error happens because lime sets PLATFORM to the wrong value due to a recent change.

However, it seems there might be a deeper problem here, because the only reason hxcpp reads PLATFORM is when it thinks you’re using an NDK version older than r20:

In your case you are trying to use r21, so that means that there might be something wrong with your setup. Please could you share your exact hxcpp version, as well as the output of lime config?

Thanks for your answer.
My hxcpp version is 4.3.2
Here is the output of lime config:

<?xml version="1.0" encoding="utf-8"?>
<config>

	<section id="defines">


	</section>
	<define name="AIR_SDK" value="/Users/chatmurai/Documents/code/AS3/SDKs/AIR_SDK_32.0" />
	<define name="ANDROID_SDK" value="/Users/chatmurai/Library/Android/sdk" />
	<define name="ANDROID_NDK_ROOT" value="/Library/Android/sdk/ndk/21.4.7075529" />
	<define name="ANDROID_SETUP" value="true" />

</config>

I’ve read the doc here Setup Android but as I said, I’m quite new at compiling for Android and I may have missed important things.

Hi, I’m totally out of my comfort zone but I believe you need to grab hxcpp from the github

Tanks for your answer! You say you’re out of your comfort zone, but as far as I’m concerned, I can say I am totally adrift :sweat_smile:

So yes, you’re right the documentation says that you can “Install a development build of hxcpp from GitHub to use Haxe 4.3” as a workaround for “Haxelib cannot build working Lime apps for Android.” but that was fixed in Support Android NDKs higher than 21 by player-03 · Pull Request #992 · HaxeFoundation/hxcpp · GitHub in 2023 and this is not the same issue I think.

Anyway I download the latest release of hxcpp (4.3.106) from github and put it into the /lib/hxcpp folder next to 4.3.2 (which is odd because it’s newer than the one I downloaded) I edited the .current file to point to the 4.3.1206 and… I get the same error :neutral_face:

Should this path be relative to your user folder? Currently it is in the root directory.

Yes thank you @tobil4sk you are absolutely right ! For some reason the file path was wrong.
Now it compiles … almost. I get an error from Gradle:

FAILURE: Build failed with an exception.

* What went wrong:
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 69
> Unsupported class file major version 69

Why not just use Adobe Air for packaging?

@785597448 I really would like to!
In the old days (like 2010 you see :old_man: ), I would code in IntelliJIdea in AS3, plugged in my Pixel phone and my iPhone via USB, hit the “test on iPhone” or “test on Android” button and voilà! But I think those days are gone forever, and I can’t find any method to compile and test in AIR directly on devices when coding in OpenFL / Haxe. Or am I wrong ?

The “Adobe Air SDK” is currently updated and maintained by Harman, and “OpenFL” can be packaged using the “Adobe Air SDK”

Maybe you can take a look

Yes that’s what I do every day for testing in ADL, but what if I want to test on my phone ?
I had a look at the Harman doc but there is no example in the Android section about packaging an APK (only AAB), or testing on a real device.

Maybe I’ll have a look to ADT tool docs but I don’t feel too confident about that, and I taught compiling to native Android app would be more efficient.

You can build for AIR with OpenFL, including getting an APK for Android and an IPA for iOS.

lime build air -android
lime build air -ios

It looks like lime test air -android and lime test air -ios should work too. They should install the app on your device and launch it, if possible. However, even if lime test doesn’t work, you can still get the APK/IPA produced by lime build and install it manually.

1 Like

I think that the only difference is that you need to specify -target apk instead of -target aab.

And -target apk-debug should package a version that can attach to a debugger.

1 Like

Thanks a lot Josh. I was able to compile to AIR for Android and install in one command with lime test air -android. It’s that simple!

I see that Haxe + Lime + OpenFL + FeathersUI are very powerful tools.
I don’t want to be rude of course, and I know that setting all this up took a huge amount of time, but I think the documentation related to compilation on different platforms could be improved, especially for beginners. If I manage to navigate through my small project, I’d be happy to contribute if needed.

I just committed a change to Lime tools that will check that the values of the config values needed for Android actually point to existing directories and report an error if they don’t. This should help make an issue of an invalid path like this much more obvious right away.

2 Likes

This error sometimes means that your Java VM is trying to run a JAR file compiled for a newer version of Java.

However, I’ve noticed that it can also happen if the various versions of Gradle tooling used for building for Android don’t match up properly with your project’s Android target-sdk-version, even if you have a new enough version of Java installed on your system.

You can customize the target-sdk-version, gradle-version, and gradle-plugin values in your project.xml. Here’s what it might look like if you simply used the default values for each of these in Lime 8.3.0:

<config:android target-sdk-version="35" gradle-version="8.9" gradle-plugin="8.7.3" />

If you happen to have changed the target-sdk-version, it’s likely that you’ll need to update the other two as well. This page has various charts that can help you choose which versions are needed for Gradle version and AGP (Gradle Plugin) version:

Just a quick tip for you! When you download an hxcpp release ZIP from GitHub, you should be able to install it like this with one command:

haxelib install ./hxcpp-4.3.106.zip

That’s good to know… For now, I will stick to compiling in Air for Android because I’m not yet familiar enough with the specifics of a native compilation. I also need to study the options in the project.xml file in more detail.

By the way, would you prefer to use the Adobe Air SDK for publishing or would you prefer to use native Android for publishing?