Recent

Author Topic: Newbie questions about cross-compile and android apk's  (Read 11868 times)

cpicanco

  • Hero Member
  • *****
  • Posts: 655
  • Behavioral Scientist and Programmer
    • Portfolio
Newbie questions about cross-compile and android apk's
« on: May 19, 2017, 04:40:15 am »
I have compiled a program using ppcrossarm. It is just a form (customdraw LCLWidget).


1) Is it possible to make an APK from this using ant?
2) If yes, how. If no, what should I do to end up with an apk??
Be mindful and excellent with each other.
https://github.com/cpicanco/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Newbie questions about cross-compile and android apk's
« Reply #1 on: May 19, 2017, 08:09:37 am »
I have compiled a program using ppcrossarm. It is just a form (customdraw LCLWidget).


1) Is it possible to make an APK from this using ant?
2) If yes, how. If no, what should I do to end up with an apk??
1) Yes
2) Make build.xml as required by ant
This is an (very) old example project of mine, I don't know if latest Android SDK/NDK & Ant can still build it or not, but you should get the idea by examining android folder in the source. Note that the files there refer to hardcoded path and keystore file (not needed for debug build AFAIR) which you must modify, because it's specific to my machine.

EDIT:
Link forgotten: https://bitbucket.org/leledumbo/javanese-chess
« Last Edit: May 19, 2017, 08:37:10 pm by Leledumbo »

cpicanco

  • Hero Member
  • *****
  • Posts: 655
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Newbie questions about cross-compile and android apk's
« Reply #2 on: May 19, 2017, 03:42:53 pm »
Thanks Leledumbo. Indeed, most docs I have found describing the ant alternative is from 2013-2011. Theses docs depends on "~/android/sdk/tools/android create project" in order to build the "build.xml" and java enviroment, afaik. So the missing part for me is how to create and configure the "build.xml". Would you mind pointing to which source this "android folder" lives?
Be mindful and excellent with each other.
https://github.com/cpicanco/

cpicanco

  • Hero Member
  • *****
  • Posts: 655
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Newbie questions about cross-compile and android apk's
« Reply #3 on: May 20, 2017, 03:54:47 pm »
So, I am really not sure where is this "android folder" you have suggested to look into. The androidlcl example is not using ant to build the apk, instead it is using another alternative (unknown for me). I am guessing it is explicitly assembling/aligning the apk file.

lazandroidmodulewizard uses ant here: 
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/demos/GUI/AppDemo1

But I am having a difficult time reading the code and "get the idea". So far I have the following:

https://github.com/cpicanco/s]"]>Blockedlus_control/blob/master/docs/compiling/cross_compiling_android.md
Be mindful and excellent with each other.
https://github.com/cpicanco/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me

Handoko

  • Hero Member
  • *****
  • Posts: 5377
  • My goal: build my own game engine using Lazarus
Re: Newbie questions about cross-compile and android apk's
« Reply #5 on: May 20, 2017, 08:06:03 pm »
2) If yes, how. If no, what should I do to end up with an apk??

If you want to build Android apk files, here are some reading materials:

http://forum.lazarus.freepascal.org/index.php/topic,33487.0.html
http://forum.lazarus.freepascal.org/index.php/topic,32472.msg209447.html
http://forum.lazarus.freepascal.org/index.php/topic,32489.msg209647.html
http://forum.lazarus.freepascal.org/index.php/topic,33428.msg216672.html#msg216672
http://forum.lazarus.freepascal.org/index.php/topic,28908.0.html
https://github.com/jmpessoa/lazandroidmodulewizard
http://forum.lazarus.freepascal.org/index.php/board,56.0.html

In short:
There are many ways available to use Lazarus/FPC to build Android apk. You should try to find which one works for you, especially these: LAMW, LazToAPK, Pandroid. LAMW probably is the best, it is well maintained, has lots of ready to use components, has no problem with Android 5+ Intel targets.

cpicanco

  • Hero Member
  • *****
  • Posts: 655
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Newbie questions about cross-compile and android apk's
« Reply #6 on: May 21, 2017, 07:08:43 pm »
Thank you so much guys, I will take a look!
Be mindful and excellent with each other.
https://github.com/cpicanco/

cpicanco

  • Hero Member
  • *****
  • Posts: 655
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Newbie questions about cross-compile and android apk's
« Reply #7 on: May 21, 2017, 07:30:56 pm »
May I ask if it is possible to completely avoid java code (expect for the jdk and ndk stuff)? Many example projects, including the LCL example itself, has a bunch of java code. I would love a 100% free pascal alternative to build apps/apks. I am pretty sure I am missing the overall strategy here. If would appreciate if someone could explain what is happening here. Is it some sort of pascal binding for the java api? Or the other way around?
Be mindful and excellent with each other.
https://github.com/cpicanco/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Newbie questions about cross-compile and android apk's
« Reply #8 on: May 21, 2017, 07:57:04 pm »
May I ask if it is possible to completely avoid java code (expect for the jdk and ndk stuff)? Many example projects, including the LCL example itself, has a bunch of java code. I would love a 100% free pascal alternative to build apps/apks. I am pretty sure I am missing the overall strategy here. If would appreciate if someone could explain what is happening here. Is it some sort of pascal binding for the java api? Or the other way around?
Yes, by using NativeActivity. This is however, is meant for you-draw-everything-yourself apps, like games. In other words, you don't get access to android GUI libraries, draw everything yourself using OpenGL ES. Another way is to use FPC JVM, but I consider this as separate environment, it's like coding Java using Pascal syntax. The amount of code you can reuse with this method is considerably low.

All existing approaches use the same base and recommended way to access Java code from other languages: JNI. But instead of directly interface with Android libraries, another wrapper is made for possibly unbounded reasons: ease of use, componentization (to make it more similar to LCL, thus allowing form designer to be used), etc. that will be harder to do if the interface is plainly done. You can check the Java code yourself, as it's normally only 2 small files (one for bootstrapping as required by Android runtime if you want to use its GUI libraries, another one for wrapping functionalities to make it simpler and easier to use).

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: Newbie questions about cross-compile and android apk's
« Reply #9 on: May 21, 2017, 08:20:05 pm »

Hello cpicanco!

As LAMW user,  you do not need code  Java or "Pascal JNI  hieroglyphs" code... just plain Pascal!

Please, go to to

https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/readme_get_start.txt

Any questions or needs we are here to help you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

cpicanco

  • Hero Member
  • *****
  • Posts: 655
  • Behavioral Scientist and Programmer
    • Portfolio
Re: Newbie questions about cross-compile and android apk's
« Reply #10 on: May 21, 2017, 09:11:43 pm »
Quote
As LAMW user,  you do not need code  Java or "Pascal JNI  hieroglyphs" code... just plain Pascal!

However, there is a bunch of java dependencies, please correct me if I am wrong. I want a minimal setup with plain free pascal code as musch as possible, pretty much like the approach suggested by Leledumbo. I need to inform myself further about this approach and confirm if any C bindings or C libraries will be needed (My problem is with Java, not C, not OpenGL).
Be mindful and excellent with each other.
https://github.com/cpicanco/

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: Newbie questions about cross-compile and android apk's
« Reply #11 on: May 21, 2017, 09:44:45 pm »
The "binds" are Android NDK, SDK and java JDK.  But, all java code is hidden for LAMW user...

Well,  LAMW is wizard! so, all you need is code in plain Pascal: RTL + FCL + [all not LCL dependent code]!
« Last Edit: May 21, 2017, 09:50:30 pm by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Newbie questions about cross-compile and android apk's
« Reply #12 on: May 22, 2017, 05:42:35 am »
However, there is a bunch of java dependencies, please correct me if I am wrong. I want a minimal setup with plain free pascal code as musch as possible, pretty much like the approach suggested by Leledumbo. I need to inform myself further about this approach and confirm if any C bindings or C libraries will be needed (My problem is with Java, not C, not OpenGL).
I wouldn't force that, since you don't have to deal with any single Java token (except those which present in Pascal as well), i.e. those Java files are prepared already and will be used transparently without you even noticing. As I said before, all existing approaches use JNI, which is the only C bindings required. There are JNI units in FPC and LAMW (based on FPC one, minimal differences due to historical reason) ready to use.

The official Android NDK utilizes the same project structure as Android SDK, in which you can't escape little Java code requirement as well. Only with NativeActivity you can, in which the required Java bootstrap code will be injected on the fly by the Android runtime. But again, that's not for common Android application.

 

TinyPortal © 2005-2018