Recent

Author Topic: Tutorial: Build APK with Castle Game Engine  (Read 3544 times)

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Tutorial: Build APK with Castle Game Engine
« on: August 11, 2018, 05:31:41 pm »
Hi, I want to share my first experience compiling an APK with Castle Game Engine, and is really good =)

I'm on Windows.

I have installed Java, Android Studio, and succesfully ran an app with that IDE, so be sure that you can do this first, is a good way to see if your device can be connected to your PC.

1) Installing Lazarus:

I used fpcupdeluxe to install trunk-trunk, then I installed the cross compiler arm-android with the same tool.

2) Install castle engine packages as described in his website
https://castle-engine.io/documentation.php

Basically is opening some lpk files, is easy.

3) Compile the build tool
https://github.com/castle-engine/castle-engine/wiki/Build-Tool

4) Set some environment variables:

ANDROID_HOME = where is installed android SDK
ANDROID_NDK_HOME = where is extracted the android NDK
CASTLE_ENGINE_PATH = where is the git repository of Castle Game Engine

in PATH add your fpc binary, I have like this:

C:\fpcupdeluxe\fpc\bin\i386-win32\

I have as well the variable JAVA_HOME.
JDK added in path as well.

Maybe these last two are not needed, and I had them because any other tool I tried in the past, I'm not sure.

5) Go to the folder where is some demo, I used the mobile folder, and then run this command:

Code: Pascal  [Select][+][-]
  1. castle-engine.exe package --os=android --cpu=arm

And then I got the apk built.

6) That apk can be installed by the same command line app, but I copy-paste it to my device.

In order to install it with the command line tool, you need to sign the apk, seems that it's easy using just a plain text file, but I will try that the next time.

Here a screenshot of the drawing app on my Android 7 device.

Well, that's all, I covered just my experience, is well documented so you will not have problems I think...

lucamar

  • Hero Member
  • *****
  • Posts: 3019
Re: Tutorial: Build APK with Castle Game Engine
« Reply #1 on: August 11, 2018, 05:36:52 pm »
Nice tut (if a little sparse ;) ). Have you considered adding it to the wiki?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Tutorial: Build APK with Castle Game Engine
« Reply #2 on: August 11, 2018, 05:41:31 pm »
Nice tut (if a little sparse ;) ). Have you considered adding it to the wiki?

Hi, yes is simple. I think it only can be usefull if is converted into a better tool. Like an already 'everything included' setup like Delphi does, so you don't need to do anything of this and just hitting the play button inside Lazarus.

lucamar

  • Hero Member
  • *****
  • Posts: 3019
Re: Tutorial: Build APK with Castle Game Engine
« Reply #3 on: August 11, 2018, 05:51:10 pm »
[...] so you don't need to do anything of this and just hitting the play button inside Lazarus.

Well, think that about 75% of your tut is basically the same as setting up Lazarus for Android development, so it's not that much. And you can run the tool by adding it as an external tool, so there goes another 20%. Not too much work, eh? 8-)
« Last Edit: August 11, 2018, 05:53:23 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Tutorial: Build APK with Castle Game Engine
« Reply #4 on: August 11, 2018, 06:22:09 pm »
Yes. But it can be better like a single setup, no path variables at all, a single download... But I know not all like that, is just my personal preference.

lucamar

  • Hero Member
  • *****
  • Posts: 3019
Re: Tutorial: Build APK with Castle Game Engine
« Reply #5 on: August 11, 2018, 10:16:43 pm »
Yes. But it can be better like a single setup, no path variables at all, a single download... But I know not all like that, is just my personal preference.

I like "click-here-and-all-will-be-done"(tm) solutions, too ... provided that what happens after the click is configurable enough  :) I've been bitten too many times by "all-automatic-whatever"s that work in 90% of cases ... and let you naked in the sun as soon as you have an even slightly tricky install (or whatever else) to perform.

Re "no path variables at all", I'm sure that it's easily doable reading the values from elsewhere: Lazarus/FPC config files, the registry in Windows, ... or taking them on the command line.

Anyway, we are programmers: applications are never done!  8)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Tutorial: Build APK with Castle Game Engine
« Reply #6 on: August 12, 2018, 01:02:10 am »
Indeed if these tools are made with no caution is worst than the tricky way.

I'm not an IDE plugin builder. But they already had some integration like project templates. Maybe a better integration will be enough.

And yes, there's no need to use path variables as you explained very well.

And of course, that will only save me some minutes. The real work must be done anyways.

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
Re: Tutorial: Build APK with Castle Game Engine
« Reply #7 on: September 05, 2018, 04:29:48 pm »
I'm on Windows.

I need the tutorial for Linux.
:) Can you please write it?

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: Tutorial: Build APK with Castle Game Engine
« Reply #8 on: October 01, 2018, 10:12:14 pm »
I'm on Windows.

I need the tutorial for Linux.
:) Can you please write it?

I'm on Windows.

Sure you can write it since you use Linux every day.

cpicanco

  • Sr. Member
  • ****
  • Posts: 465
    • My Portfolio
Re: Tutorial: Build APK with Castle Game Engine
« Reply #9 on: October 07, 2018, 09:28:27 pm »

Handoko

  • Hero Member
  • *****
  • Posts: 3752
  • My goal: build my own game engine using Lazarus
Re: Tutorial: Build APK with Castle Game Engine
« Reply #10 on: October 08, 2018, 03:54:55 am »
Thank you for the link. I'll try it when I have time.

 

TinyPortal © 2005-2018