x86 target for Android is not working


Ok, Android and JUCE apps work great for armeabi-v7a.

When I target only x86 to test on my Intel Android tablet I get a crash.

To get this I just APP_ABI := x86 in my Application.mk.

I can run any non-JUCE NDK app and everything is fine, this problem only occurs with JUCE apps (not just mine!).

So, I fired up ndk-gdb and I found that some weird pointer stuff is going on.

Basically on the C++ side @ juce_android_Messaging.cpp MessageManager::postMessageToSystemQueue() a pointer to a message is passed to the Java function postMessage().

This is good, then on the Java side, postMessage() will make a new MessageCallback that is a Runnable object. When it executes with MessageCallback::run(), it passes that pointer value (a long on the Java side) back to C++ with the native function deliverMessage() @ juce_android_Messaging.cpp:50. When I look at this pointer value in the eclipse debugger, it is valid.

The value passed around is supposed to be a 32 bit pointer, but when it is passedd back to C++ from Java it has all 64 bits filled. It seems to have bits swapped. The valid pointer bits are in the high 32 bits and the low 32 are filled with junk. If my pointer looked like 0x12345678 when it was passed Java, when it is returned it looks like 0x123456789abcfef0. The high bits being the only valid ones.

To confirm, inside juce_android_Messaging.cpp::deliverMessage(), I shift the passed in value by 32 bits:

value = value >> 32;

This transforms the value back into the original pointer that was passed to Java in the first place via postMessageToSystemQueue(). I confirmed all of this with a bunch prints.

With this hack, my app seems to have run fine, but I didn't test it too much. I have other tasks so I'm not going to focus on this one, but I'd love to figure out what is going on here. Plus, there could be some other issues with x86 builds if pointers are passed into Java and back to C++.

In the meantime I'll continue to just target ARM.

Any ideas on a proper fix that would be universal? I didn't want to mess with the JNI macros too much.



Try this (it may not cover all you've said above ), but, as I've not used/needed to build an x86 target, I don't know.

IMHO,  the place to select the target that ought to be in the specific Android->Debug/Release Architechture field of Introjucer .jucer projects

{Note If you have multiple targets. you can also have multiple Android projects, one for armeabi one for armeabi-v7a, another for x86 } - build each, and see which work/don't perhaps?


Hope this hepls


I haven't tried rebuilding with the introjucer with a different architecture. I was thinking that all I needed was to update the APP_ABI field in the Application.mk for this but I guess there could be some other stuff going on. I'll try that out when I get a chance.

That assumes that the Introjucer generates different code for x86 Android. Obviously the ideal would be having the same Android Juce code but maybe slight differences defined by preprocessor directive (Example X86_ANDROID and ARM_ANDROID).




My Intel friend got in touch with Jules, Jules fixed the bug.

I downloaded the latest juce code and now I can target and compile for X86 Android Intel devices and there are no more crashes. Good.