Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiDemoFiremonkey

Bare Bones Android App With NDK Shared Object Built In Delphi XE7 Without Firemonkey

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE7 Bare Bones Android App Without Firemonkey | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSDeveloper 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.

Head over and check out the full source code for the three necessary files for creating your bare bones Delphi XE7 Android app without Firemonkey.

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.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

Leave a Reply