[SOLVED] Http requests with Android lazarus / 43-Android ---------------------------------------------------------------------- tintinux · 2016-04-14 06:28 Hi With Synapse I can perform Http Get request on Windows, Linux and OS/X. On Android it compiles but when a get request is done the application ends  without message. Of course, I have enabled Internet access in the manifest. I'm using LazToApk targetting an Android 4 system (not working with Android >= 5) I do not find anything in the log, but maybe I have not the tool for that (can't connect with adb on this phone) Was anyone successful in this area, with Synapse or another library ? Thanks for hints. ---------------------------------------------------------------------- hnb · 2016-04-14 07:20 Try to use mORMot. Works for me very well on Android. ---------------------------------------------------------------------- tintinux · 2016-04-14 09:28 OK, thanks, I will try, but : 1) is it really free software ? 2) does it now works on Linux 64 bits  ? Regards ---------------------------------------------------------------------- BeniBela · 2016-04-14 12:45 Android has its own Java http libraries You can call those with JNI. I wrote a wrapper to call the HttpComponent library. Sadly, they were deprecated in Android 22 and seemingly removed in Android 23. ---------------------------------------------------------------------- hnb · 2016-04-15 12:41 Quote from: tintinux on April 14, 2016, 11:28:49 am1) is it really free software ? 2) does it now works on Linux 64 bits  ? 1) yes very liberal licence. 2) AFAIK 32 bits Linux, but that part maybe will work for 64 bits ---------------------------------------------------------------------- tintinux · 2016-04-15 17:54 Quote from: BenibelaI wrote a wrapper... I suppose it is internettools...  which looks a simple and efficient library (just the opposite of mORMot). Is there any hope you will search why it is deprecated on the recent Android SDK, and make it working ? I only need httpRequest from internetaccess.pas and even not https. This would be great ! Regards ---------------------------------------------------------------------- BeniBela · 2016-04-15 21:42 Quote from: tintinux on April 15, 2016, 07:54:30 pm I suppose it is internettools...  which looks a simple and efficient library (just the opposite of mORMot). It is probably rather inefficient, when it calls Java functions for everything Quote from: tintinux on April 15, 2016, 07:54:30 pmIs there any hope you will search why it is deprecated on the recent Android SDK, and make it working ? Google put an unreleased alpha  version of the HttpComponents in the early Android  and then they could not update it for backward compatibility, so it was just sitting there as legacy lib. And they say the HttpURLConnection is more efficient nowadays. It seems they only removed it from the SDK, so it still works on the devices. You just cannot compile java sources that uses it and it is undocumented. But who knows how long. androidinternetaccess.pas is the file containing the wrapper ---------------------------------------------------------------------- Leledumbo · 2016-04-16 07:34 Quote from: tintinux on April 14, 2016, 08:28:50 amWith Synapse I can perform Http Get request on Windows, Linux and OS/X. On Android it compiles but when a get request is done the application ends  without message. Of course, I have enabled Internet access in the manifest. ... Was anyone successful in this area, with Synapse or another library ? Works fine on my phone. One of the LazAndroidModuleWizard demos (the GUI one) also does HTTP request, which also works fine, requesting the same http://www.freepascal.org as in my screenshot. Quote from: tintinux on April 14, 2016, 08:28:50 amI do not find anything in the log, but maybe I have not the tool for that (can't connect with adb on this phone) logcat can be run on the device itself and there's an app in the play store wrapping that. ---------------------------------------------------------------------- tintinux · 2016-04-20 10:10 Hi Quote from: leledumboOne of the LazAndroidModuleWizard demos (the GUI one) also does HTTP requestCould you say which one more precisely or where it can be found ? The "GUI" source I find in demo folder (AppAntDemo1) is displaying 2 buttons, a timer and "Lazarus Rocks", and I do not see any Http Request. The only other is "NOGUI". Quote from: leledumbologcat can be run on the device itself and there's an app in the play store wrapping that Yes, thanks. However it seems necessary to be root, and I have not found how root to with adb not working... Maybe I will try to find another more standard phone, because the one I have require specific adb drivers not working. Regards ---------------------------------------------------------------------- Handoko · 2016-04-20 14:23 Quote from: tintinux on April 20, 2016, 12:10:41 pmCould you say which one more precisely or where it can be found ? Here: [your_lazandroidmodulewizard_folder]/trunk/demos/Eclipse/AppDemo1 ---------------------------------------------------------------------- jmpessoa · 2016-04-20 16:00 Yes, and more: "lazandroidmodulewizard"\demos\Eclipse\AppHttpClientDemo1 "lazandroidmodulewizard"\demos\Eclipse\AppHttpClientDemo2 "lazandroidmodulewizard"\demos\Eclipse\AppHttpClientCookiesDemo1 NOTE: All LAMW/eclipse project are "Ant"  compatibles! Please, see "readme.txt" how to use demos: To use/test any demo App you will need: 1. Open the project ...  "...\jni" . Upgrade your project [or demo] code templates:     Lazarus IDE --> menu Tools --> [Lamw] Android Module Wizard --> Upgrade code Templates [*.lpr, *.java] 2. configure "build.xml"  to match your system... and "AndroidManifest.xml": "android:targetSdkVersion"   to match "build.xml" 3. configure the ".lpi" to match your system... NOTE 1: if you need configure for "x86" please, go to folder "...\jni\build-modes"  and see "readme.txt" to replace some lines in ".lpi" NOTE 2. The LAMW produce many ".bat" or ".sh" to logcat ... there are more in  "...\utils", too 4. Lazarus IDE --> Run --> "build"   [to produce the pascal jni ".so"] 5. Connect your Device-PC  via usb ... 6. Lazarus IDE --> Run --> "[Lamw] Build Android Apk and Run" Thanks to All! ---------------------------------------------------------------------- tintinux · 2016-05-02 07:39 Ok, the jHttpClient installed with LAMW works fine for me ! ---------------------------------------------------------------------- JD · 2016-05-02 09:08 Quote from: hnb on April 14, 2016, 09:20:59 amTry to use mORMot. Works for me very well on Android. What version of FPC are you using with it? I've been unable to compile the mORMot example because of a compiler error with FPC 3.0 JD ---------------------------------------------------------------------- DonAlfredo · 2016-05-02 10:06 For the mORMot, I always use trunk. With the RTTI patch for more convenience (on i386 and x86_64): https://github.com/LongDirtyAnimAlf/Reiniero- fpcup/blob/master/patchfpc/fpctrunkrtti.patch (I am busy at the moment to get the method invoke working for ARM !) ---------------------------------------------------------------------- tintinux · 2016-05-02 10:31 Hi I use currently FPC3.1.1 as specified in this page But I have not used mORMot because it is mixing Http and SqlLite in a strange way, and I do not need SqlLite at all. So, I only use the jHttpClient installed with LAMW, and it works fine. Hope this helps. ---------------------------------------------------------------------- Thaddy · 2016-05-02 10:37 Quote from: tintinux on May 02, 2016, 12:31:31 pm But I have not used mORMot because it is mixing Http and SqlLite in a strange way, and I do not need SqlLite at all. Then that's a bug in mORMot. Report it. It usually gets fixed pretty quick. There should never be a dependency on sqlite like that. ---------------------------------------------------------------------- DonAlfredo · 2016-05-02 13:09 SQLite3 is not needed for a plain http server by mORMot. See Sample 9 in the Samples directory. ---------------------------------------------------------------------- BeniBela · 2016-05-02 13:25 Perhaps it is an issue with Lazarus' packages, because they always compile all units, not just those used?