Recent

Author Topic: APK creation on mac  (Read 13171 times)

Handoko

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #15 on: August 02, 2016, 05:35:32 pm »
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

  • New Member
  • *
  • Posts: 39
Re: APK creation on mac
« Reply #16 on: August 02, 2016, 05:41:50 pm »
Yes I start new project and it is work now :) Now i will try build apk :)

Handoko

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #17 on: August 02, 2016, 05:43:59 pm »
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

  • New Member
  • *
  • Posts: 39
Re: APK creation on mac
« Reply #18 on: August 02, 2016, 06:52:30 pm »
Now I create android_release.keystore
And the main question is how create apk?

Handoko

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #19 on: August 02, 2016, 07:19:47 pm »
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][+][-]
  1. export PATH=/usr/bin:$PATH
  2. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  3. cd /home/handoko/Projects/Project Software/Android Test/LamwGUIProject1
  4. ant -Dtouchtest.enabled=true debug

This is my generated build script (build-release.sh):
Code: Pascal  [Select][+][-]
  1. export PATH=/usr/bin:$PATH
  2. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  3. cd /home/handoko/Projects/Project Software/Android Test/LamwGUIProject1
  4. ant clean release

This is my generated build.xml:
Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="LamwGUIProject1" default="help">
  3.   <property name="sdk.dir" location="/home/handoko/Android/sdk"/>
  4.   <property name="target" value="android-19"/>
  5.   <property file="ant.properties"/>
  6.   <fail message="sdk.dir is missing." unless="sdk.dir"/>
  7.   <import file="${sdk.dir}/tools/ant/build.xml"/>
  8. </project>

This is my AndroidManifest.xml:
Code: Pascal  [Select][+][-]
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.lamw.lamwguiproject1" android:versionCode="1" android:versionName="1.0">
  3.   <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19"/>
  4.   <uses-permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE"/>
  5.   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  6.   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  7.   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  8.   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  9.   <uses-permission android:name="android.permission.BLUETOOTH"/>
  10.   <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
  11.   <uses-permission android:name="android.permission.CALL_PHONE"/>
  12.   <uses-permission android:name="android.permission.CAMERA"/>
  13.   <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
  14.   <uses-permission android:name="android.permission.INTERNET"/>
  15.   <uses-permission android:name="android.permission.NFC"/>
  16.   <uses-permission android:name="android.permission.READ_CONTACTS"/>
  17.   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  18.   <uses-permission android:name="android.permission.READ_OWNER_DATA"/>
  19.   <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  20.   <uses-permission android:name="android.permission.RECEIVE_SMS"/>
  21.   <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
  22.   <uses-permission android:name="android.permission.SEND_SMS"/>
  23.   <uses-permission android:name="android.permission.VIBRATE"/>
  24.   <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
  25.   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  26.   <uses-permission android:name="android.permission.WRITE_OWNER_DATA"/>
  27.   <uses-feature android:name="android.hardware.camera" android:required="false"/>
  28.   <uses-feature android:name="android.hardware.camera.flash" android:required="false"/>
  29.   <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
  30.   <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
  31.   <uses-feature android:name="android.hardware.telephony" android:required="false"/>
  32.   <uses-feature android:name="android.hardware.sensor.stepcounter" android:required="false"/>
  33.   <uses-feature android:name="android.hardware.sensor.stepdetector" android:required="false"/>
  34.   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true"/>
  35.   <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
  36.     <activity android:name="org.lamw.lamwguiproject1.App" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize|screenLayout|fontScale" android:launchMode="standard" android:enabled="true">
  37.       <intent-filter>
  38.         <action android:name="android.intent.action.MAIN"/>
  39.         <category android:name="android.intent.category.LAUNCHER"/>
  40.       </intent-filter>
  41.     </activity>
  42.   </application>
  43. </manifest>

This is the script to generate keystore (release-keystore.sh):
Code: Pascal  [Select][+][-]
  1. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  2. cd /home/handoko/Projects/Project Software/Android Test/LamwGUIProject1
  3. keytool -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.
« Last Edit: August 02, 2016, 07:27:58 pm by Handoko »

saashapont

  • New Member
  • *
  • Posts: 39
Re: APK creation on mac
« Reply #20 on: August 03, 2016, 10:52:53 am »
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

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #21 on: August 03, 2016, 11:29:06 am »
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.

Can 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

  • New Member
  • *
  • Posts: 39
Re: APK creation on mac
« Reply #22 on: August 03, 2016, 11:34:29 am »
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

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #23 on: August 03, 2016, 11:50:11 am »
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
Quote
Libraries: /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/ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/bin

Note:
Quote
And 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

  • New Member
  • *
  • Posts: 39
Re: APK creation on mac
« Reply #24 on: August 03, 2016, 03:03:25 pm »
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

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #25 on: August 03, 2016, 03:28:12 pm »
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

  • Jr. Member
  • **
  • Posts: 67
Re: APK creation on mac
« Reply #26 on: August 03, 2016, 04:19:54 pm »
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:

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/ndk/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!
FPC 3.0.5 | Lazarus 1.8 | Ubuntu Gnome 17.10 64bit

Handoko

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #27 on: August 03, 2016, 05:19:41 pm »
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][+][-]
  1. cd ~handoko/Projects/"Project Software"/"Android Test"/Demo/bin
  2. adb 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

  • New Member
  • *
  • Posts: 39
Re: APK creation on mac
« Reply #28 on: August 04, 2016, 10:42:23 am »
Are there any new virtual machine for android development? I try to use filippe's 2011 year?

Handoko

  • Hero Member
  • *****
  • Posts: 4140
  • My goal: build my own game engine using Lazarus
Re: APK creation on mac
« Reply #29 on: August 04, 2016, 10:49:04 am »
I've been checking this forum regularly since one or 2 years ago. Never heard any new release of virtual machine for android development.

 

TinyPortal © 2005-2018