Developer Simon,Choi has released some source code for building a bare bones Android app in Delphi XE7 with the Firemonkey framework. Basically it is a really slimmed down Android NDK shared object with a bare bones Android SDK app that calls into the Android SDK shared object. A shared object (*.so) file is like a Windows DLL and is what your Delphi XE7 Object Pascal app gets compiled down into. An Android SDK java app wraps the shared object and loads your app from the shared object library. Normally the library contains the Firemonkey framework which has a pretty good size. Simon also released a similar project for a bare bones XE7 IOS app. The sample code from Simon allows you to create an Android NDK shared object library in Object Pascal that does not contain the Firemonkey framework. It would also appear that you could distribute this shared object as part of your own SDK to other developers to use in their java Android SDK applications. I think it would be pretty rough to build anything without all of the Firemonkey functionality (including the non visual components) but this gives you that option. The shared object exports functions which can be called directly from Java. Here is some code from the project where it demonstrates how to load the shared object and it’s exported function in Java:
public class Tester {
// Load Library
static { System.loadLibrary("tester"); }
public native int pTest (int value);
}
And here is some sample Object Pascal code from the project that shows how to create a function and export it from the Delphi XE7 Object Pascal shared object file:
Function pTest (env: PJNIEnv; this: jobject; value : integer): integer; cdecl;
begin
Dbg( MarshaledAString( 'pTest >> In:' +IntToStr(Value) + 'Out:' + IntToStr(Value+100)));
Result := Value + Inx;
Inc(Inx);
end;
exports
JNI_OnLoad name 'JNI_OnLoad',
JNI_OnUnload name 'JNI_OnUnload',
calc name 'calc',
pTest name cFuncPrefix+'pTest';
And lastly here is some pieces of code from the example which show how to load the above Java class and Android NDK shared object and call the Delphi XE7 function in Java:
public Tester tester;
tester = new Tester();
int rst = tester.pTest(123);
The instructions are a little bit unclear because it talks about a build batch file but I don’t see that anywhere. I assume you just build the Delphi XE7 project and then compile and pack your two Java classes as an Android SDK with the shared object file from XE7 in the appropriate directory. This project should probably also compile in Appmethod.
There is also a second page which more extensive instructions which is linked from the first but I’m not sure how it applies to the first project other than it tells how to setup building for the Android SDK.
Lastly here are the three source files for the bare bones Delphi XE7 Android shared object and app.