Welcome, Guest
Username: Password: Remember me
CodeTyphon Android Development, LAMW, etc, discussions and problems
  • Page:
  • 1

TOPIC:

I have found ready to use solution on how to pack the application to *.APK file. 8 months 2 hours ago #19007

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
I have read this wiki article "Cross-build for Android".

pilotlogic.com/sitejoom/index.php/wiki/1...als/cross-build.html

In the end of it, it is said that
"For Deploy your new application, or how to pak your app to *.APK file,
Please seach to the web..."

I have started to search to the web...

On SourceForge.net I have found ready to use example made by Key-Real.

He is from Hamburg, Germany.

He made Pascal program for Android Camera.

!!!With Android permissions granted for Camera and Storage!!!.

Here is the link.

sourceforge.net/p/nativeandroidcamera/code/ci/master/tree/


I think, I have found out some main ideas of this example: 

1. Pascal program must be library unit to create .so file.

2. Because .so file is library in Android.

3. As library unit program must have external function to import.

4. To start the application on Android device the external function of the .so file must be set as application.MainActivity in Manifest file for Android.

5. After producing .so file it has to be copied into "lib" folder of Android application template given by the author.



I think, that this example could be used as Template to create any other Pascal application for Android.

Because:

1. The author has created all folders requried to create APK with Manifest file. 

2. The author has created ready to use build-script to create signed APK and sign it.


Script named doit can be found in the root folder!


All you need is to change the content in the folders of the APK template. 

sourceforge.net/p/nativeandroidcamera/code/ci/master/tree/apk/


And run the script named doit.

I think, it is great!

Author done well!
The following user(s) said Thank You: choki

Please Log in or Create an account to join the conversation.

I have found ready to use solution on how to pack the application to *.APK file. 6 months 2 weeks ago #19064

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
Because of apk file in repository is broken, in attach there is ready to use apk. 

It works on my Android 12. 

Install it, close it after installation, do not open, then launch it again.

Of course, this example could be better if there were Forms and buttons added.

To manage camera.

In such case, I think, the library file .so for Android should be compiled with LCLWidgetType=customdrawn as it support Android graphics.

And OpenGLES30.pas library could be replaced with OpenGL components.

File Attachment:

File Name: myapp.zip
File Size:1,899 KB
Attachments:

Please Log in or Create an account to join the conversation.

I have found ready to use solution on how to pack the application to *.APK file. 6 months 2 weeks ago #19065

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
If you have troubles with building apk file, you can use the apk file from attach in previous message.

1. Change extension of myapp.apk file to myapp.zip.

2. Open it with any unzip application. I use WinRar.

3. Go to lib folder inside archive.

4. Replace library files .so in folder arm64-v8a for Android 64 and in folder armebi-v7a for Android 32.

5. Save changes to archive and close it.

6. Change back extension from myapp.zip to myapp.apk.

7. Sign modified apk with any apk manager. I use MT Manager.


Notice while changing code in mynativeapplication.pas library file do not touch the names of exported function.
 
These function are required for Java and Android to launch the app.

The link to the mynativeapplication.pas library file is still active. 
Here it is.
sourceforge.net/p/nativeandroidcamera/co...mynativeapplication/


Key-real, the author of the project, really done well!


 

Please Log in or Create an account to join the conversation.

I have found ready to use solution on how to pack the application to *.APK file. 5 months 2 weeks ago #19087

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
I have found the old way to create Android apk from Lazarus project. 
The same technology: apk template, library and java launcher.

The difference is that Forms and LCL Controls are included and work.
Take a look to this article.wiki.lazarus.freepascal.org/Custom_Drawn_Interface/Android

In this article instructions are given.

The sample code of the library and Android apk template you can find in the old versions of Lazarus IDE.


I think the sample from old Lazarus IDE will work.
Because it is the same technology as sample of native_android_camera mentioned above. With Forms and Controls from LCL included.


 

Please Log in or Create an account to join the conversation.

Last edit: by Ak.Saharov.

I have found ready to use solution on how to pack the application to *.APK file. 4 months 2 weeks ago #19149

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
There many examples in CodeOcean.

I have found the CT app to pack the library .so into Android .apk file.
My directory is path C:\codetyphon\CodeOcean\10_App\samples\AndroidHeadersBuilder

I have opened and compiled this project.
I have run it and created the Template for Android .apk file.
To my directory path C:\Programs\zeljus\Primjer01\android

The Java launcher for Android Main Activity is named LCLActivity.java
To load the library .so when Android app is starting.   
LCLActivity.java is placed in the directory C:\Programs\zeljus\Primjer01\android\src\com\pascal\systeminfo

I found out that it is required to run the file named "build_debug_apk.bat".
In the directory C:\Programs\zeljus\Primjer01\android

To build debug apk it is required to put library .so file named liblclapp.so in directory "libs".

The directory "libs" is empty.

Anybody, please, tell me where is the liblclapp.so?

Or, maybe I could use my own .so file if I change the library name to load in LCLActivity.java? 

In case I can use my own library, what Pascal code I need to put in my library? 

       

Please Log in or Create an account to join the conversation.

Last edit: by Ak.Saharov. Reason: Forgot to add screenshot

I have found ready to use solution on how to pack the application to *.APK file. 4 months 2 days ago #19158

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
I still want Mr. ex-Pilot to answer my questions. About library for the sample template of Android application. Or maybe he's already Mr. Dead Pilot?

Please Log in or Create an account to join the conversation.

I have found ready to use solution on how to pack the application to *.APK file. 2 weeks 3 minutes ago #19319

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
I have found library I mentioned above in Laz4Android 1.4.4 (folder Examples).

Then I converted this library project in CT 8.7 with CTC convert utility. 

After that I changed project setting - set new path to Android API 2.3 in CT 8.7.

I built the library and create apk with ant utility from Android studio.

I launched apk in Android Studio Virtual Device with Android 2.3.

Controls on the Forms are clickable. 

There are 2 forms and you can switch from form to form.

More information you can see on the screenshots attached.

Also I have attached the project folder in zip archive for everybody who wants to try.

The created apk is in the subfolder android\bin. It is unsigned.

To sign the apk I use MT Manager.

 

File Attachment:

File Name: android_ctp_1501.zip
File Size:2,531 KB
Attachments:

Please Log in or Create an account to join the conversation.

I have found ready to use solution on how to pack the application to *.APK file. 1 week 6 days ago #19320

  • Ak.Saharov
  • Ak.Saharov's Avatar Topic Author
  • Away
  • Junior Member
  • Junior Member
  • Posts: 47
  • Thank you received: 1
If someone is interested to upgrade this project for actual Android devices, here is road map:

1. Install Android Studio - version with "ant" utility.

2. Install suitable platforms in Android studio.

3. Install Java 17.

4. Unzip archive on drive in root. I did it on C:\ 

Otherwise check the project setting (first of all check the path to compiled library).

5. Make suitable path in OS system variables to java, ant and etc. 

6. Go to project folder

7. Open subfolder \android

8. Check the path in files local.properties and default.properties.

9. Open cmd terminal and go to project folder into subfolder "android".

10. Run command in terminal - ant release (from subfolder android).

11. The created apk is in the subfolder android\bin. It is unsigned.

12. To sign the apk use any suitable Manager. I use MT Manager.

13. Create Android Virtual Device or use the smartphone with Android to test.

14. Use adb utility to install apk into Android Virtual Device.


More information you can find on the screenshots attached.

 
Attachments:

Please Log in or Create an account to join the conversation.

I have found ready to use solution on how to pack the application to *.APK file. 1 week 6 days ago #19321

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1331
  • Thank you received: 208
Thanks Sir
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

  • Page:
  • 1