Build apk package for Android from a c/c++ engine

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Fabio Gobbato
Posts: 217
Joined: Fri Apr 11, 2014 10:45 am
Full name: Fabio Gobbato

Build apk package for Android from a c/c++ engine

Post by Fabio Gobbato »

How to build and apk package for Android from a c/c++ engine?
In the past I have used the compiler in the NDK and built an executable but it seems it doesn't work anymore to Android so the only solution is to create an apk package. I've installed Android Studio but I don't fully understand how the engine should be called from the java code. I've read that the engine have to support the OEX standard but I've not found descriptions of this standard. I've googled a lot but I've not found any informations. Could you help me?
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Build apk package for Android from a c/c++ engine

Post by abik »

Hi Fabio,

Here you can find details on the Android Open Exchange format (OEX). There is also the Android Chessbase compatible format, but that never became widespread because Chessbase insisted on keeping this a proprietary format. Chess for Android supports both formats though.

You can read a bit more on why engines no longer import as before (which made me really sad as well) in this W^X thread.
Aart
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Build apk package for Android from a c/c++ engine

Post by Ras »

Looks really complicated, with the reference site not even working properly.

Alternative: install Droidfish from the Fdroid store and use engines as executables like before. Problem solved.
Rasmus Althoff
https://www.ct800.net
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Build apk package for Android from a c/c++ engine

Post by abik »

Ras wrote: Wed Jul 07, 2021 9:53 pm Looks really complicated, with the reference site not even working properly.
Yeah, I guess that site did not age well. Probably a better place to browse around is gkalab's github, although I am not sure where the official site (if any) resides nowadays (pointers welcome so I can update my website links too).
pedrojdm2021
Posts: 157
Joined: Fri Apr 30, 2021 7:19 am
Full name: Pedro Duran

Re: Build apk package for Android from a c/c++ engine

Post by pedrojdm2021 »

The possible solutions that comes to my mind are:

1) Unity project, you need to know C# and how to use unity game engine, you build your C++ engine into a .dll library and then you make a "wrapper" in C# that calls the native code into your C++ plugin, it is basically a "brige" between C# application and your C++ plugin.

2) Microsoft's Xamarin, the same as Unity, you need to import your engine as a library and use it in the C# application.

3) Google's Android studio, i think that there is a way to import C++ plugins into android studio, but this time you'll need to know Java or Kotlin

Some links:

Android studio:
https://developer.android.com/studio/pr ... ative-code

Xamarin:
https://docs.microsoft.com/en-us/xamari ... tform/cpp/

Unity:
https://joinerda.github.io/DLLs-And-Unity/

Good luck!

Another thing: be sure that you don't use any OS specific features into your C++ code, or you'll end up with tons of errors, or at least be sure that your code is fully multi-platform!
petero2
Posts: 688
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: Build apk package for Android from a c/c++ engine

Post by petero2 »

You can have a look at the texel app project here:

https://github.com/peterosterlund2/texelapp

I don't think it uses the latest version of the OEX code but it works for me anyway.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Build apk package for Android from a c/c++ engine

Post by xr_a_y »

Ras wrote: Wed Jul 07, 2021 9:53 pm Looks really complicated, with the reference site not even working properly.

Alternative: install Droidfish from the Fdroid store and use engines as executables like before. Problem solved.
This is working fine indeed, but is droidfish handling tourney or just engine versus human ?
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Build apk package for Android from a c/c++ engine

Post by Ras »

xr_a_y wrote: Wed Jul 14, 2021 11:30 ambut is droidfish handling tourney or just engine versus human ?
No idea. I don't regard engine tournaments on a phone as relevant use case.
Rasmus Althoff
https://www.ct800.net