Android JNI or native code

Within the next couple months? Android support is working pretty well, but I’m not yet sure how we want to support the JNI helper stuff (but I know it’s important for extensions) :slight_smile:

Oki, thank you :yum:

Hi guys

It’s been a while and I’ve avoided really getting into openfl because of the lack of JNI support since I mainly write android apps. What’s the status of the JNI support as of now?

It’s been a few months now.

Looks like it’s available for both legacy and next!

I tried to build legacy app (3 JNI extensions) without -Dlegacy flag and it’s compiled fine, but after run i got the errors:

E/ExtendedExtractor: Failed to open MM_PARSER_LIB, dlerror = Cannot load library: load_library[1096]: Library 'libmmparser.so' not found 
E/ExtendedExtractor: Failed to open MM_PARSER_LITE_LIB, dlerror = Cannot load library: load_library[1096]: Library 'libmmparser_lite.so' not found 
A/libc: Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1)

Full logs:


Is that related to your application, or a native extension? I’ve never heard of that library before – not related to OpenFL.

Perhaps you could try an OpenFL sample, first, and see if those are running for you without legacy?

Do you now… I tried to compile openfl-samples 3,3,1.
“openfl test flash” - works fine
“openfl test android” - compilation error at the end for all projects (with -Dlegacy flag same):

C:\android\sdk\tools\ant\build.xml:888: The following error occurred while executing this line:
C:\android\sdk\tools\ant\build.xml:890: The following error occurred while executing this line:
C:\android\sdk\tools\ant\build.xml:902: The following error occurred while executing this line:
C:\android\sdk\tools\ant\build.xml:283: null returned: 1

PS: Win 7 x64, all haxe libs are fresh, android sdk, ndk, java sdk and ant from “openfl setup android” command

Weird. Are your Android build tools up-to-date?

PS: Win 7 x64, all haxe libs are fresh, android sdk, ndk, java sdk and ant from “openfl setup android” command

+Yes, android sdk updated too.

and “platform build tools”, etc through the SDK manager? I can’t say I’ve seen this before

Yes, ofc through sdk manager)
I will try to compile openfl-samples on office PC tomorrow. And on wife’s notebook =)

Google returned me back to forum)
Problem was with “,” symbols in path openfl-samples\3,3,1… Android Build tools doesn’t like this chars =
Samples work fine now on android.

Joshua recommends copying the sample project into another folder using “openfl create [sample project name].” I assume that’s so you can make changes without messing up the original, but this could be another reason.

1 Like

Yes, i read samples readme, but i’m so lazy :grin:

But sample with text fields throws the error:

I/trace   (18578): Assets.hx:240: [Assets] There is no Font asset with an ID of "assets/LIBERATIONSERIF-REGULAR.TTF"

And my app without legacy flag gets runtime crash when i try to create textfield.

var mainFont:String = Assets.getFont("fonts/obelix.ttf").fontName;
var smallTipsFont:String = Assets.getFont("fonts/europanuova.ttf").fontName;	
Lib.trace("mainFont = " + mainFont);
Lib.trace("smallTipsFont = " + smallTipsFont);

Android -Dlegacy output:

mainFont = fonts/obelix.ttf
smallTipsFont = fonts/europanuova.ttf

Without flag, same device:

mainFont = ����������������ˆ󛸰󚈈
smallTipsFont = ����󦅰��������Ԁ������������𰐐����񰜀

What is the font name of these fonts when you open them on your computer? (Windows font info, Mac font book, etc)

(BTW, here’s the fix in the sample https://github.com/openfl/openfl-samples/commit/db0f70f2300982a4aab2c2cd8adbccb963b1bb61)

Names of my fonts: ObelixPro and EuropaNuovaRegular.

I made this fix in my samples copy. I got same results:
legacy build - app works fine

20344-20405/org.openfl.samples.textmetrics I/trace﹕ Lib.hx:548: font name = assets/LiberationSerif-Regular.ttf

next build - app is crashes

19767-19797/org.openfl.samples.textmetrics I/trace﹕ Lib.hx:144: font name = ����������������������������

App runs on 2 different android devices.

Does this work if you try on a platform other than Android?

-DNext

//HTML Lib.hx:144: font name = Liberation Serif
//Flash Lib.hx:144: font name = Liberation Serif
//Neko Lib.hx:144: font name = Liberation Serif

-Dlegacy Neko

//Neko Lib.hx:548: font name = assets/LiberationSerif-Regular.ttf

Other platforms can’t compile. And for html build i converted ttf file to eot, woff and svg fotmats. But “Wqx” text didn’t appear on canvas.

Alright, so maybe there’s a wide character (unicode) issue on Android that needs to be resolved here. The new OpenFL is supposed to (like Flash) use the real font name for the font name, rather than an asset path :slight_smile:

1 Like