I managed to produce an apk file suitable for Android on Intel CPUs instead of ARM CPUs using the same build_debug_apk.bat file with a few modifications. So here is what I did:
1-Get NDK Toolchains Assembler and Linker for x86:
First I copied both
i686-
android-
linux-as.exe
i686-
android-
linux-ld.exe
from:
android-ndk-r7c\toolchains\x86-4.4.3\prebuilt\windows\bin
2-Change Names:
later I discovered that the cross compiler ppc386.exe is using different name for these files so I changed their names according to that to:
i686-
linux-
android-as.exe
i686-
linux-
android-ld.exe
which is simply switching
android and
linux positions!!
3-Generate Android-i386 version
I modified laz4android\build.bat to build the packages for Android on i386. I believe I did something like this:
- make clean all bigide+ cd C:\laz4android\fpc\2.7.1\source\packages
+ make clean all install OS_TARGET=android CPU_TARGET=i386 INSTALL_PREFIX=C:\laz4android\fpc\mine
After I ran this build batch file I went to check C:\laz4android\fpc\mine where I found units\
i386-android\*
I moved
i386-android folder to its expected location under
laz4android\fpc\2.7.1\units next to arm-android folder
4-Modifications to
Compiler OptionsOn Lazarus IDE menu I went to Project->Project Options or Shift+Ctrl F11. When the window opened up I chose "Build Modes" under "Compiler Option" on the left to add another
build mode. Renamed the original one as Android-arm, and the new one as Android-x86. Then made Android-x86
active to change its settings.
-Chose "Paths" on the left:
---Under "Libraries (-Fl)" replaced the previous one with
android-ndk-r7c\platforms\android-14\arch-
x86\usr\lib\
---Under "Target file name (-o)"
android\libs\
x86\liblclapp.so
-Chose "Code Generation" on the left
---For "Target CPU family (-P) I chose
i386. Not a surprise!
-Chose "Other" on the left
---Under "Custom option" deleted "-CpARMV6" so it became -dANDROID -Xd (Not sure it was needed, but did it anyway)
After that I built the library. To check that the file it produced was really for Intel I used Cygwin terminal, moved toward liblclapp.so folder and typed in "file liblclapp.so"
the result was
liblclapp.so: ELF 32bit LSB shared object, Intel 80386, version 1 (SYSV) dynamically linked, stripped
Curious to know more, I tried also "ldd" in Cygwin which confused me by claiming that the shared library is dependent on ntdll.dll and kernel32.dll which is
NOT true.
5-Modifications to build_debug_apk.bat
replaced
armeabi with
x86, for instance, it has to create a folder named "x86" instead of "armeabi"
-
mkdir %APK_PROJECT_PATH%\raw\lib\armeabi+ mkdir %APK_PROJECT_PATH%\raw\lib\
x86and so on...
Then I tested the resultant apk file on Android and I made sure that it does not have Houdini library - a library used in Android on Intel CPUs that allows using ARM libraries and it worked!!