Recent

Author Topic: Android Module Wizard  (Read 707716 times)

euller

  • New Member
  • *
  • Posts: 16
Re: Android Module Wizard
« Reply #585 on: August 26, 2015, 09:19:22 pm »
Hello guys, does any of you has seen this error in your applications:

Code: [Select]
A/libc(30743): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
My application crashes, and logcat show this message, whenever I try to use jHttpClient.OnContentResult.

After some digging, I've found that after Android 4.0, they've changed the memory management and, most of JNI codes present this same kind of error. Does it makes sense also in LAMW?
The best way to find a if a tool is faulty; is to use it in a stupid way for stupid purposes

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #586 on: August 26, 2015, 10:29:38 pm »
Hello , installing the package the nuts do Lazarus me this , why?

Compile package tfpandroidbridge_pack 0.0: Codice di uscita 1, Errori: 1
androidwidget.pas(15,44) Fatal: Impossibile trovare CustApp usato da AndroidWidget del pacchetto tfpandroidbridge_pack.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #587 on: August 27, 2015, 05:53:31 am »
@Euller,

Quote
... I've found that after Android 4.0 ...

No, In my test, I compiled with android 4.2  [target 4.2, too], and it is ok!


@xinyiman

In my system the source of "CustApp" is in "C:\laz4android\fpc\x.y.z\source\packages\fcl-base\src"

and your "homemade" android cross-compile should generate "custapp.tpu" in "...\fpc\x.y.z\units\arm-android"

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #588 on: August 27, 2015, 12:44:36 pm »
@xinyiman

In my system the source of "CustApp" is in "C:\laz4android\fpc\x.y.z\source\packages\fcl-base\src"

and your "homemade" android cross-compile should generate "custapp.tpu" in "...\fpc\x.y.z\units\arm-android"


a question, this guide "new_how_to_install_by_renabor.txt"  is still valid and relevant to install everything on linux? Or it is partial and must follow another?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #589 on: August 27, 2015, 01:22:37 pm »
Hello @xinyiman!

I've updated the guide, integrating it with more specific steps.
A note on fpc version, that must be 2.6.4 for compiling the trunk version (3.1.1).
If you have Ubuntu 14.04 (like me) you must download the correct version from here:
http://packages.ubuntu.com/vivid/fpc-2.6.4

Thank you!

#######################
(replace $HOME with your username)

################
install some necessary programs:

(CMD) sudo apt-get install android-tools-adb ant fp-compiler openjdk-7-jdk subversion

################
(CMD) mkdir ~/Android
(CMD) cd ~/Android

################
install Android NDK
################

Download Android NDK from https://developer.android.com/ndk/downloads/index.html#download
follow instruction to install it

create a symbolik link for later use

(CMD) ln -s /home/$HOME/Android/android-ndk-r10e /home/$HOME/Android/ndk

################
create symbolic link for linker
################

(CMD) cd /usr/bin
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
(CMD) sudo ln -s /home/$HOME/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-as arm-linux-as
(CMD) sudo ln -s /usr/bin/arm-linux-androideabi-ld arm-linux-ld

################
install Android Sdk
################
Download Android Sdk from https://developer.android.com/sdk/index.html#Other (SDK Tools Only)
and extract it

(CMD) tar xzvf android-sdk_r24.3.4-linux.tgz

create a symbolik link for later use

(CMD) ln -s /home/$HOME/Android/android-sdk-linux /home/$HOME/Android/sdk

################
install SDK packages
################
Follow these instructions
https://developer.android.com/sdk/installing/adding-packages.html

and install SDK packages
(CMD) ~/Android/sdk/tools/android sdk

################
modify your PATH
################
Add to your ~/.bashrc:
export PATH=$PATH:~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin

################
download FPC and LAZARUS
################

svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co http://svn.freepascal.org/svn/fpc/trunk fpc

################
install other needed packages
################
(ref.: http://wiki.freepascal.org/How_to_setup_a_FPC_and_Lazarus_Ubuntu_repository)
sudo apt-get install libgtk2.0-dev libgdk-pixbuf2.0-dev libgpm-dev fakeroot libncurses5-dev libtinfo-dev

################
BUILD FPC.DEB
################

(CMD) cd ~/Android/lazarus/tools/install
(CMD) ./create_fpc_deb.sh fpc /home/$HOME/Android/fpc/

################
purge fpc from system
################

REMOVE all fpc deb and fp_ deb (fpc, fpc-src, fp_compiler and so on)
(EX) sudo dpkg --remove fpc* fp-*

################
INSTALL the new trunk fpc package
################

(CMD) sudo dpkg -i ./fpc_3.1.1-150130_amd64.deb

################
BUILD FPC-SRC.DEB
we need source for fpc, now we create it, and install it
################

(CMD) ./create_fpc_deb.sh fpc-src /home/$HOME/Android/fpc/
(CMD) sudo dpkg -i fpc-src_3.1.1-150130_amd64.deb

################
BUILD LAZARUS.DEB AND INSTALL IT
################

(CMD) ./create_lazarus_deb.sh append-revision
(CMD) sudo dpkg -i lazarus_1.5.47565-0_amd64.deb

################
BUILD THE CROSS COMPILER
################

cd ~/Android/fpc
make clean crossall OS_TARGET=android CPU_TARGET=arm
sudo make crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr

################
create symbolic link for newly created arm compiler
################

(CMD) cd /usr/bin
(CMD) sudo ln -s /usr/lib/fpc/3.1.1/ppcrossarm .
(CMD) sudo ln -s /usr/bin/ppcrossarm ppcarm

################
update /etc/fpc.cfg
################
Add these lines to /etc/fpc.cfg

#IFDEF ANDROID
#IFDEF CPUARM
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
#ENDIF

################
install LAMW
################

(CMD) svn co https://github.com/jmpessoa/lazandroidmodulewizard.git
(CMD) ln -s /home/$HOME/Android/svn-lazandroidmodulewizard/trunk /home/$HOME/Android/lazandroidmodulewizard

################
Install LAMW on Lazarus
################

1. From Lazarus IDE - Install Wizard Packages
  1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk"  [Android Components Bridges!]
     1.1.1 From Package Wizard
                                - Compile
                                - Use -> Install
  1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
     1.2.1 From Package Wizard
                                - Compile
                                - Use -> Install
  1.3 Package -> Open Package -> "amw_ide_tools.lpk"  [folder: ..\LazAndroidWizard\ide_tools]
     1.3.1 From Package Wizard
                                - Compile
                                - Use -> Install

2. From Lazarus IDE menu Tools -->> "Android Module Wizard" --> Paths Settings"
  update paths settings according to your system
(ref. https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA1OF9yVVU3RA)

     -Path to Java JDK (ex. /usr/lib/jvm/java-7-openjdk-amd64)
     -Path to Android SDK( ex. /home/renabor/Android/sdk)
     -Path to Ant bin (ex. /usr/bin)
     -Select Ndk version: [10]
     -Path to Ndk (ex  /home/$HOME/Android/android-ndk-r10e)
     -Path to Java Resources  [Simonsayz's Controls.java,  *.xml and default Icons]: (ex. /home/$HOME/Android/svn-lazandroidmodulewizard/trunk/java)

################
BUILD YOUR FIRST PROJECT
################

Open a project from lazandroidmodulewizard/demos/Ant or lazandroidmodulewizard/demos/Eclipse directory
open ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1/jni/controls.lpi
from Project->Options, change/modify paths according to your system (under «paths» and «other»)

(ex. for «paths» ../../../Android/android-ndk-r10e/platforms/android-21/arch-arm/usr/lib;/home/$HOME/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/)

(ex. for «other» -Xd -CfSoft -CpARMV6 -XParm-linux-androideabi- -FD/home/$HOME/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin)

build it!

################
################
compile for ARM
################
################

from shell
(CMD) cd ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1

################
build.xml
################

<?xml version="1.0" encoding="UTF-8"?>
<project name="AppDemo1" default="help">
<property name="sdk.dir" location="/home/$HOME/Android/sdk"/>
<property name="target"  value="android-19"/>
<property file="ant.properties"/>
<fail message="sdk.dir is missing." unless="sdk.dir"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>

################
build.sh
################

edit build.sh leaving only this line:

   ant -Dtouchtest.enabled=true debug

################
install.sh
################

remove content of install.sh and replace it with:

/home/$HOME/Android/sdk/platform-tools/adb uninstall com.example.appdemo1
/home/$HOME/Android/sdk/platform-tools/adb install -r bin/AppDemo1-debug.apk
/home/$HOME/Android/sdk/platform-tools/adb logcat

################
Connect a device
################

run an emulator
(CMD) ~/Android/sdk/tools/android avd &

################
COMPILE AND INSTALL
################

(CMD) chmod +x ./build.sh && chmod +x ./install.sh
(CMD) ./build.sh
(CMD) ./install.sh

Enjoy!
« Last Edit: August 29, 2015, 07:21:57 pm by renabor »
FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #590 on: August 27, 2015, 01:25:21 pm »
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
« Last Edit: August 27, 2015, 01:46:59 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

euller

  • New Member
  • *
  • Posts: 16
Re: Android Module Wizard
« Reply #591 on: August 27, 2015, 06:38:36 pm »
I've discovered the problem. but still didn't find a solution.
Here is the deal, when I call jHttpClient.OnContentResult, I receive a string named content right? Well, I use this string to fill a JSON array, and use that array to fill a ListView, and boom, crashes. Right now I'm digging up the reason, I will tell when more information is available.
The best way to find a if a tool is faulty; is to use it in a stupid way for stupid purposes

euller

  • New Member
  • *
  • Posts: 16
Re: Android Module Wizard
« Reply #592 on: August 27, 2015, 09:28:11 pm »
New info, doesn't matter where the code is, it simply doesn't work, here, a sample of how it looks:

Code: [Select]
procedure TMiniActivity.PopulateList(content: String);
var
  vja: TJSONArray = nil;
  i: Integer;
  s: String;
begin
  if Trim(content) <> '' then
  begin
    try
      s:='';
      vja:= TJSONArray(GetJSON(content));
      for i:=0 to vja.Count-1 do
      begin
        s:= vja.Objects[i].Strings['data_a']+' - '+vja.Objects[i].Strings['data_2'];
        jListView1.Add(s);
      end;
    except
      ShowMessage('Operation error');
    end;
    FreeAndNil(vja);
  end;
end;

I've done this code over and over for desktop and web applications, but in android with LAMW it doesn't work. I'm starting to suspect that is something I'm totally oblivious going on and I've ran out of ideas of how to find it. Does someone has any thoughts?
The best way to find a if a tool is faulty; is to use it in a stupid way for stupid purposes

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: Android Module Wizard
« Reply #593 on: August 28, 2015, 12:02:28 am »
@Euller,

I Think your problem in " JSON" cross-compile support...  In my sytem I have:

"C:\laz4android\fpc\x.y.z\units\arm-android\fcl-json"

and you ?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android Module Wizard
« Reply #594 on: August 28, 2015, 09:00:32 am »
New info, doesn't matter where the code is, it simply doesn't work, here, a sample of how it looks:

Code: [Select]
procedure TMiniActivity.PopulateList(content: String);
var
  vja: TJSONArray = nil;
  i: Integer;
  s: String;
begin
  if Trim(content) <> '' then
  begin
    try
      s:='';
      vja:= TJSONArray(GetJSON(content));
      for i:=0 to vja.Count-1 do
      begin
        s:= vja.Objects[i].Strings['data_a']+' - '+vja.Objects[i].Strings['data_2'];
        jListView1.Add(s);
      end;
    except
      ShowMessage('Operation error');
    end;
    FreeAndNil(vja);
  end;
end;

I've done this code over and over for desktop and web applications, but in android with LAMW it doesn't work. I'm starting to suspect that is something I'm totally oblivious going on and I've ran out of ideas of how to find it. Does someone has any thoughts?
At least 2:
  • Make a good use of the raised exception object, try-except can explain more precisely what happens
  • ShowMessage the content before passing it to GetJSON, make sure it really is a valid JSON

euller

  • New Member
  • *
  • Posts: 16
Re: Android Module Wizard
« Reply #595 on: August 28, 2015, 01:09:23 pm »
@Euller,

I Think your problem in " JSON" cross-compile support...  In my sytem I have:

"C:\laz4android\fpc\x.y.z\units\arm-android\fcl-json"

and you ?

yes, I do

At least 2:
  • Make a good use of the raised exception object, try-except can explain more precisely what happens
  • ShowMessage the content before passing it to GetJSON, make sure it really is a valid JSON

I've done that, this code was to simply show the situation
The best way to find a if a tool is faulty; is to use it in a stupid way for stupid purposes

renabor

  • Jr. Member
  • **
  • Posts: 73
Re: Android Module Wizard
« Reply #596 on: August 28, 2015, 07:03:43 pm »
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
Thank you! I'm trying install LAMW in a fresh lubuntu virtual machine too, but I have problems in preparing lazarus deb package, the error is:

(9022) Compiling resource ../units/i386-linux/gtk2/lazarus.or
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Error: (9030) Can't call the resource compiler "/usr/bin/fpcres", switching to external mode
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crti.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crtn.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Fatal: (10026) There were 1 errors compiling module, stopping

revisions of fpc and lazarus are retrieved with:

svn co -r 49563 http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co -r 31226 http://svn.freepascal.org/svn/fpc/trunk fpc

/usr/bin/fpcres is still present in my system, but not used, why?!?
Have you had better result?


FPC 3.2.2 | Lazarus 2.2.3 | Kubuntu 22.04 64bit

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #597 on: August 28, 2015, 08:55:03 pm »
Thanks you're an angel. Really I want to create a virtual machine (virtualbox) with Lubuntu (latest version - 15.4) in order to release it to those wishing to try download without exhausting in preparing the car.
Thank you! I'm trying install LAMW in a fresh lubuntu virtual machine too, but I have problems in preparing lazarus deb package, the error is:

(9022) Compiling resource ../units/i386-linux/gtk2/lazarus.or
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Error: (9030) Can't call the resource compiler "/usr/bin/fpcres", switching to external mode
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crti.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Warning: (9034) "crtn.o" not found, this will probably cause a linking failure
/home/renabor/tmp/lazarus1.5.49563/lazarus_build/usr/share/lazarus/1.5.49563/ide/lazarus.pp(144,1) Fatal: (10026) There were 1 errors compiling module, stopping

revisions of fpc and lazarus are retrieved with:

svn co -r 49563 http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co -r 31226 http://svn.freepascal.org/svn/fpc/trunk fpc

/usr/bin/fpcres is still present in my system, but not used, why?!?
Have you had better result?

Hello , I went addition , the preparation of the deb package of Lazarus had no problems . I have no problem about this command because you did not specify from which folder I launch

make clean crossall OS_TARGET=android CPU_TARGET=arm

~/Android/fpc?!
« Last Edit: August 28, 2015, 09:15:23 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android Module Wizard
« Reply #598 on: August 28, 2015, 11:00:06 pm »
When install tfpandroidbridge_pack.lpk
Why?!

Costruisci la IDE: Codice di uscita 512, Errori: 1, avvertimenti: 2
lazarus.pp(144,1) Warning: "crti.o" not found, this will probably cause a linking failure
lazarus.pp(144,1) Warning: "crtn.o" not found, this will probably cause a linking failure
/usr/bin/ld: warning: ../link.res contains output sections; did you forget -T?

/usr/bin/ld: cannot find -lGL
lazarus.pp(144,1) Error: Error while linking
« Last Edit: August 28, 2015, 11:06:16 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

euller

  • New Member
  • *
  • Posts: 16
Re: Android Module Wizard
« Reply #599 on: August 29, 2015, 04:33:02 pm »
Hey guys, here is what I think is the reason of my problem:

http://stackoverflow.com/questions/14495242/android-fatal-signal-11-sigsegv-at-0x00000040-code-1-error

If you look at the answer instead of the question as I did, you may came to the same conclusion I had: the two problems have the same reason, but I could be wrong. So please help me to find an answer.
The best way to find a if a tool is faulty; is to use it in a stupid way for stupid purposes

 

TinyPortal © 2005-2018