APK creation on mac
lazarus / 43-Android
----------------------------------------------------------------------
saashapont · 2016-07-26 13:00
Are there any tutorial about creation of apk files from Lazarus on Mac
computer. I read about this for linux and windows^ but this solutions
is not work
----------------------------------------------------------------------
skalogryz · 2016-07-26 13:05
how come linux solution doesn't work? (what linux instructions did you
follow?)
----------------------------------------------------------------------
saashapont · 2016-07-26 13:12
I try to use this
http://wiki.lazarus.freepascal.org/Android_Interface#Configuring_the_F
ree_Pascal_Compiler_for_Android
And I cannot do part
Compiling the example LCL Android Application
----------------------------------------------------------------------
skalogryz · 2016-07-26 13:17
Quote from: saashapont on July 26, 2016, 03:12:48 pmAnd I cannot do
part
Compiling the example LCL Android Application
is there a particular error message shown? what exactly stops you?
----------------------------------------------------------------------
saashapont · 2016-07-26 13:21
I compile well for other linux arm device^ but when i add folder
/Volumes/MacHD2/Android/android-ndk-r10e/platforms/android-21/arch-
arm to the library i have errors
Compile Project, OS: linux, CPU: arm, Target: project1: Exit code 256,
Errors: 1
/sw/bin/arm-linux-ld: warning: link.res contains output sections; did
you forget -T?
/Volumes/MacHD2/Android/android-ndk-r10e/platforms/android-21/arch-
arm/usr/lib//libc.so: warning: the use of `pthread_attr_getstackaddr'
is deprecated, use `pthread_attr_getstack'
/Volumes/MacHD2/Android/android-ndk-r10e/platforms/android-21/arch-
arm/usr/lib//libc.so: warning: the use of `pthread_attr_setstackaddr'
is deprecated, use `pthread_attr_setstack'
/sw/bin/arm-linux-ld: /sw/lib/fpc/3.0.0/units/arm-
linux/rtl/cwstring.o: undefined reference to symbol
'nl_langinfo@@GLIBC_2.4'
/sw/bin/arm-linux//libc.so.6: error adding symbols: DSO missing from
command line
project1.lpr(22,0) Error: Error while linking
----------------------------------------------------------------------
skalogryz · 2016-07-26 15:04
Why are you using arm-linux as target? Should it be arm-android
instead?
At least it appears like you're mixing arm-linux libs and arm-android
(ndk) libs.
Android is more or less a fork of linux, thus mixing linux and android
libs is undesirable.
----------------------------------------------------------------------
saashapont · 2016-07-26 15:23
Are there any precompile croscompilators for android on mac?
----------------------------------------------------------------------
Handoko · 2016-07-27 03:05
There are several options to build APKs using Lazarus/FPC:
- FPC JVM
http://wiki.lazarus.freepascal.org/FPC_JVM_Android_Development
- Laz4Android
This package uses Custom Drawn Interface.
https://sourceforge.net/projects/laz4android/
- LazToApk
This tool will help you automatically download Laz4Android, Android
SDK & NDK, configure and perform cross compiling.
https://sourceforge.net/projects/laztoapk/
- Lazarus Android Module Wizard (LAMW)
It has its own Form Designer and lots of ready to use components.
https://github.com/jmpessoa/lazandroidmodulewizard
- LazSDL2Design Package
Similar to LAMW, it has its own Form Designer and components.
http://forum.lazarus.freepascal.org/index.php/topic,33008.0.html
All of them are able to build simple Android apps, but I don't think
they're mature enough for serious production use for now. And your
chances for success are better if you use it on Windows or Linux
environment. For Mac users, you can use VirtualBox:
https://www.virtualbox.org/wiki/Downloads
----------------------------------------------------------------------
tintinux · 2016-08-02 06:14
Quote from: handoko- Laz4Android
This package uses Custom Drawn Interface.
Are you sure ?
AFAIK it's LazToApk which is using CD Interface. And unfortunately CD
interface currently doesn't work on Android >= 5.
Or things have changed ?
Regards
----------------------------------------------------------------------
Handoko · 2016-08-02 06:54
Quote from: tintinux on August 02, 2016, 08:14:02 amQuote from:
handoko- Laz4Android
This package uses Custom Drawn Interface.
Are you sure ?
Perhaps, I was wrong.
I ever installed Laz4Android and LazToApk, and performed some simple
tests only. Because as mentioned, Custom Drawn Interface has issue
with Android 5, so I stopped to learn deeper.
After I installed Laz4Android, I got impression that Laz4Android was
using Custom Drawn Interface because the tutorial told us to enable
Custom Drawn package (in section: Rebuild Laz4Android IDE):
http://wiki.lazarus.freepascal.org/Android_tutorial
If I'm not wrong, although Laz4Android is using Custom Drawn by
default, it can support LAMW too.
----------------------------------------------------------------------
saashapont · 2016-08-02 13:50
OK now I make croscompiller from 3.1.1 for android and it is work from
command line like
sudo /sw/bin/ppcrossarmAndroid -Tandroid -Parm -XS -dANDROID -Xd
-CpARMV6 -FLlibdl.so hello.pas
I want try to use Custom Drawn Interface controls.
1. I install this package
2. Create new project
3. set Target OS android Target CPU arm Target processor default,
Target file name : android\libs\armeabi\liblclapp.so, Enable strip
symbols (-Xs)
And has error
Hint: (11030) Start of reading config file /sw/etc/fpc.cfg
Hint: (11031) End of reading config file /sw/etc/fpc.cfg
Free Pascal Compiler version 3.1.1 [2016/08/02] for arm
Copyright (c) 1993-2016 by Florian Klaempfl and others
(1002) Target OS: Android for ARMEL
(3104) Compiling lcl.pas
(3104) Compiling ./gtk2/alllclintfunits.pas
(3104) Compiling ./gtk2/gtk2cellrenderer.pas
/sw/share/lazarus/lcl/interfaces/./gtk2/gtk2cellrenderer.pas(30,3)
Fatal: (10022) Can't find unit gtk2 used by Gtk2CellRenderer
Fatal: (1018) Compilation aborted
How i can fix that?
----------------------------------------------------------------------
Handoko · 2016-08-02 14:05
Did you compiling it on Mac? Or Linux?
If you're using Mac, I will suggest you to use VirtualBox. Android
development using Lazarus/FPC hasn't properly tested on Mac. I'm not a
Mac user, nothing much I can help.
If you're a Windows user, I will recommend you to try Laz4Apk first
which is much more beginner friendly.
If you're a Linux user, LAMW would be the best one. I specialize
myself in using LAMW. It might be a bit challenging for newbies, but
if you follow the documentation properly, there should be no problem.
Good luck!
edited:
I saw the error messages you provided. It seems you haven't properly
install Custom Drawn package, because there are many "gtk" things
found in the messages.
----------------------------------------------------------------------
saashapont · 2016-08-02 14:09
Mac, i try to use it
----------------------------------------------------------------------
Handoko · 2016-08-02 14:14
I guess, what you've done is just Cross Compile to Android
preparation. You still have to install Custom Drawn Interface. More
info here:
http://wiki.lazarus.freepascal.org/Android_tutorial
Follow the link above and find the "Rebuild Lazarus IDE" topic (near
the end of page).
Or follow this steps:
1. Goto Lazarus main menu
2. Package > Install/Uninstall Packages
3. On the right side, type "custom drawn", then select "customdrawn
0.0"
4. Click the "Install selection" button
5. Click the "Save and rebuild IDE" button
----------------------------------------------------------------------
saashapont · 2016-08-02 15:19
i did it
----------------------------------------------------------------------
Handoko · 2016-08-02 15:35
And the issue still there. On the compiler messages, it said ... bla3
... gtk cannot be found. Isn't it?
Is yes, then you maybe haven't set your IDE to use Custom Drawn
interface as your current widgetset. Try this:
1. Lazarus main menu > Configure "Build Lazarus"
2. LCL widget type = customdrawn (alpha)
3. Target OS = [your OS]
4. Target CPU = arm
5. Press the build button
6. After the rebuilding process, your Lazarus will restart
7. Close all files and start a new application project
8. Have fun
Now, you should having multiple widgetsets. You old android project
maybe not be set to use Custom Drawn, I guess it was configured to use
GTK. So, you should start a new android project.
And remember if you want to make new project next time, you may need
to set it to proper widgetset depend on your target OS. I'm not very
sure: GTK is for Linux and Windows. QT and Carbon can be used for Mac
target. Custom Drawn is for Android and some others.
http://wiki.lazarus.freepascal.org/Widgetset
----------------------------------------------------------------------
saashapont · 2016-08-02 15:41
Yes I start new project and it is work now Now i will try build apk
----------------------------------------------------------------------
Handoko · 2016-08-02 15:43
Aah, that's great.
Remember, now your IDE is configured to use multiple widgetsets. You
should pay attention on what widgetset to use everytime you start a
new project. I can't tell you more, because I rarely experiment with
multiple widgetsets.
Have fun!
----------------------------------------------------------------------
saashapont · 2016-08-02 16:52
Now I create android_release.keystore
And the main question is how create apk?
----------------------------------------------------------------------
Handoko · 2016-08-02 17:19
As I'm not a Mac user, nothing much I can say.
But you may have a look on the available tutorials and adapt it to
your environment. If I'm not wrong to generate the apk file, you will
need these things:
- Java & Ant are installed correctly on your system
- Build script (release or debug)
- File: build.xml
- File: AndroidManifest.xml
- File: release-keystore
Because I use LAMW, all the necessary files mentioned above are
generated automatically. So the thing I need to do is simply run the
build script, I choose the debug script. And the apk file will be
generated.
You may have a look on this Windows tutorial (see Deployment section):
http://wiki.lazarus.freepascal.org/Android_tutorial
This is my generated build script (build-debug.sh):
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i export
PATH=/usr/bin:$PATHexport JAVA_HOME=/usr/lib/jvm/java-7-openjdk-
amd64cd /home/handoko/Projects/Project Software/Android
Test/LamwGUIProject1ant -Dtouchtest.enabled=true debug
This is my generated build script (build-release.sh):
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i export
PATH=/usr/bin:$PATHexport JAVA_HOME=/usr/lib/jvm/java-7-openjdk-
amd64cd /home/handoko/Projects/Project Software/Android
Test/LamwGUIProject1ant clean release
This is my generated build.xml:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
This is my AndroidManifest.xml:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
This is the script to generate keystore (release-keystore.sh):
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i export
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64cd
/home/handoko/Projects/Project Software/Android
Test/LamwGUIProject1keytool -genkey -v -keystore
LamwGUIProject1-release.keystore -alias lamwguiproject1aliaskey
-keyalg RSA -keysize 2048 -validity 10000 <
/home/handoko/Projects/Project Software/Android
Test/LamwGUIProject1/lamwguiproject1keytool_input.txt
I have copy-pasted the files needed for generate apk, you can use them
after modifying them to match your environment.
----------------------------------------------------------------------
saashapont · 2016-08-03 08:52
thank you for answer!
1.Create app with one form and custom drawn button
2. I make all files
3. Then signed apk
4. Install to the phone
5. It crashed on start
Can you make same simple project with form and try to test it on real
device and upload it?
----------------------------------------------------------------------
Handoko · 2016-08-03 09:29
What is your Android version? Is it version 5 or above? If yes, then
you've been warned. tintinux already mentioned Custom Drawn doesn't
work on Android 5 and above. Try to run the same apk on Android 4, it
could run properly.
Anyways, congratulations for your success to create apk on Mac. Could
you please do us a favor? As you've already known there is lack of
information about how to generate Android apk using Lazarus/FPC on
Mac. The community will thanks you a lot if you're willing to write a
wiki page explaining the process to create apk using Lazarus/FPC on
Mac.
Quote from: saashapont on August 03, 2016, 10:52:53 amCan you make
same simple project with form and try to test it on real device and
upload it?
I managed to generate fat binaries (ARM and Intel) apk to run on my
Intel-based Android 5 device showing hundreds of textured 2D
rectangles moving randomly on the screen with Z-order using OpenGL
ES2. I don't use Custom Drawn, I use LAMW.
----------------------------------------------------------------------
saashapont · 2016-08-03 09:34
No, i have not new android device i use api 16
Yes of course, I will try to make tutorial when i get working app
----------------------------------------------------------------------
Handoko · 2016-08-03 09:50
The toolchain to generate Android apk is complicated. If we're not
careful, a tiny mistake could cause the result application fail to
start even without warning on the compilation/building process. Try to
pay attention on these things:
- minSdkVersion, targetSdkVersion, version of your SDK and NDK
- You have to configure project option properly (menu > Project >
Project Options)
Here is my project option setting for Android arm target
QuoteLibraries: /home/handoko/Android/ndk/platforms/android-21/arch-
arm/usr/lib/
Target file name: ../libs/armeabi/libcontrols
Target CPU family: arm
Custom Options: -Xd -CfSoft -CpARMV7A -XParm-linux-androideabi-
-FD/home/handoko/Android/ndk/toolchains/arm-linux-
androideabi-4.6/prebuilt/linux-x86/bin
Here is my project option setting for Android Intel target
Quote# Android LAMW for i386 Target
Libraries:
/home/handoko/Android/ndk/platforms/android-21/arch-x86/usr/lib/
Target file name: ../libs/x86/libcontrols
Target CPU family: i386
Custom Options: -Xd -XPi686-linux-android- -FD/home/handoko/Android/nd
k/toolchains/x86-4.9/prebuilt/linux-x86_64/bin
Note:
QuoteAnd this is my environment
Installed NDK: 11c
Min SDK: 15
Target SDK: 19
NDK Platform: 21
My home folder: /home/handoko
Android folder: /home/handoko/Android
Android NDK folder: /home/handoko/Android/android-ndk-r11c
Android SDK folder: /home/handoko/Android/android-sdk-linux
----------------------------------------------------------------------
saashapont · 2016-08-03 13:03
Ok New little report.
The app building on mac works good.
The problem in compilation part.
I download virtual machine and try to make lcldemo. Then i transfer it
to the mac and build apk. It is work.
But when i try to compile on mac. The process is over with success.
But app crash after start.
On the old vm target is arm linux... may be it a key...
----------------------------------------------------------------------
Handoko · 2016-08-03 13:28
Pay attention on the compiler settings especially the Custom Options:
-Xd -CfSoft -CpARMV7 -XParmlinux...
If your OS is Linux, then there must use linux. So if you're using
Mac, there should ... I don't know, mac perhaps.
----------------------------------------------------------------------
renabor · 2016-08-03 14:19
Quote from: Handoko on August 03, 2016, 11:50:11 amThe toolchain to
generate Android apk is complicated. If we're not careful, a tiny
mistake could cause the result application fail to start even without
warning on the compilation/building process. Try to pay attention on
these things:
Here is my project option setting for Android Intel target
Quote# Android LAMW for i386 Target
Libraries:
/home/handoko/Android/ndk/platforms/android-21/arch-x86/usr/lib/
Target file name: ../libs/x86/libcontrols
Target CPU family: i386
Custom Options: -Xd -XPi686-linux-android- -FD/home/handoko/Android/nd
k/toolchains/x86-4.9/prebuilt/linux-x86_64/bin
Hello @Handoko!
Can you tell me how to compile with ant the libcontrols build for the
target i386-android?
And how to install the apk in an emulator?
Thank you!
----------------------------------------------------------------------
Handoko · 2016-08-03 15:19
There are no special tricks. When I click the "Android [GUI] JNI
Module [Lamw]" on Lazarus menu > new, all the files required for
building apk will be generated automatically by LAMW.
I just have to make sure the project options has configured correctly.
My environment and project options settings can be found on this
thread:
http://forum.lazarus.freepascal.org/index.php/topic,33410.0.html
After configure the settings properly, then I compile the source code.
The result binary will be created in the libcontrols folder. I simply
use File Manager (Caja) to browse to the project folder and run the
build-debug.sh script. FYI, the build-debug.sh and build-release.sh
scripts are generated by LAMW and not set to "allow executing file as
program", so we have to manually enable it.
After Running the build-debug.sh, an apk will be generated in bin
folder. To install the apk on emulator:
1. Start the Linux Terminal
2. Use cd command to goto the bin folder
3. Execute this command: adb install Demo-debug.apk
Here I copy pasted the complete text:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i cd
~handoko/Projects/"Project Software"/"Android Test"/Demo/binadb
install Demo-debug.apk
Note:
- I use debug script. Release script should be ok, but I never tried.
- Both the build scripts (debug & release) need to set chmod +x.
----------------------------------------------------------------------
saashapont · 2016-08-04 08:42
Are there any new virtual machine for android development? I try to
use filippe's 2011 year?
----------------------------------------------------------------------
Handoko · 2016-08-04 08:49
I've been checking this forum regularly since one or 2 years ago.
Never heard any new release of virtual machine for android
development.