RTC Forums

Subscription => Support => Topic started by: manoi on September 17, 2013, 09:02:32 AM



Title: Delphi XE5 Android Support
Post by: manoi on September 17, 2013, 09:02:32 AM
Do you have any news on Delphi XE5 Android device support ?


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on September 17, 2013, 10:26:27 AM
It should be ready for release in October or November.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: manoi on September 18, 2013, 03:44:30 AM
Thank you.

I use your product almost in every project (Windows , iOS (lazarus, XE5)) and the performance is very good.


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on September 18, 2013, 08:21:36 AM
Glad to hear that :)

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: Ronald van Tour on September 19, 2013, 11:22:18 AM
Good news !
Installed XE 5 yesterday (2013-09-18) This morning build my first demo APP for Android ad now working on my HTC phone.
Can not wait to use the RTC components with android support !




Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on September 19, 2013, 12:11:55 PM
Everyone interested in development for the Android platform, please download the RTC SDK v6.21 (just uploaded) and give it a try.

Sould you bump into any problems, let me know.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: Ronald van Tour on September 19, 2013, 12:43:16 PM
OK Thanks. Downloaded and installed.

I have a form with a RTCHttpClient and a RTCClientModule.
When I compile I get a message file not found my documents\myproject\rtcdatacli.dcu
I copy this file to myproject just for testing when I compile I get a fatal error bad unit format expected version 26.0 ARM found version 26.0 Windows Unicode


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on September 19, 2013, 12:52:31 PM
You need to add the path to the RTC SDK "Lib" folder to Delphi for every platform ("Tools/Options" menu, "Environment Options / Delphi Options / Library" -> "Selected Platform:" Win32, Win64, OSX, iOS, Android) and you will need to BUILD your Project to make sure all files are compiled for the correct platform (COMPILE does not do that).

If you don't add the path, Delphi will be unable to find the files.
And if you don't use BUILD (but only COMPILE), Delphi will try using files compiled for other platforms.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: Ronald van Tour on September 19, 2013, 01:03:49 PM
Thanks for the Result.

I added the folder to the RTC SDK "Lib" Folder.
But I noticed you must do this for each platform.
I have Build the project.
Now it works.


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on September 19, 2013, 01:14:43 PM
Good to hear that.

I have tested the components with a few simple Projects, but since everything is affected by the new ARC (Auto Refference Counting) when building Projects for Mobile platforms with Delphi XE4 or XE5, there could be memory issues which did not surface in my tests, so I would appreciate it if anyone using the components for iOS or Android would let me know if they encouter any problems, or if everything works just fine.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: manoi on September 19, 2013, 01:59:01 PM
Thank you for quick update. It's work very well.


Title: Re: Delphi XE5 Android Support
Post by: Ronald van Tour on September 19, 2013, 04:39:03 PM
I agree. I have a working APP now on my HTC where I can see the temperatures that is posted by an arduino on my RTC server.
And only in 1 day.


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on September 19, 2013, 04:44:41 PM
That is great feedback. Thank you, guys.
Should you bump into any issues, please do let me know.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 23, 2013, 10:06:57 AM
I am writing a simple program based on online Time demo. And then the Android Client. Client write in Windows works, but not Android client on HTC. Am I doing something wrong, or latest RTC 6.23 does not work yet for Android?

Thanks

Jim


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 23, 2013, 11:08:23 AM
What exactly does not work? Are you getting an exception, or are you unable to connect, or is the connection working but you can not send data? I need a bit more information to answer your question.

Does your HTC phone use WLAN to connect to your Server, or are you using a mobile connection from your HTC phone to connect to the Server and your internet router is configured to forward incoming connections to the Server?

If you are accessing your Server over a mobile connection on your HTC phone, and you have correctly configured your internet router to allow incoming connections to the Server, did you also configure the Server to work with mobile providers as explained in this Quick Start Topic (https://rtcforum.teppi.net/index.php?topic=683.0)?

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 23, 2013, 06:00:46 PM
On the server, I used RtcHttpServer, Port 80, Adding FuncGroup, Module, Function components as the demo. Function to serve time. FileName is /TEST, Function is TIME
At the client (Both Windows and Android clients), I use the RtcHttpClient and ClientModule. It is over WIFI LAN, on actual HTC device not on simulator or mobile connection. IP address 192.160.0.235. The router is configured correctly. I wrote a similar simple Indy IdTcpServer-Client demo, and it works on HTC. And I've tried FixupRequest.RemovePrevix, true and false. Tried both fmt_RTC and fmt_XMLRPC.

During debug (of the HTC client), when call client's "Execute", it shows an exception "connection problem". Could be something I did wrong, that I don't know off. The exactly same client code wrote in Windows works.

Is there an android working demo I can try out and trace?

Thanks Danijel

Jim


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 23, 2013, 07:09:22 PM
All Projects from the SDKDemos_FMX2 Project Group should work with Delphi XE5 on Android devices.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 23, 2013, 07:23:03 PM
To simplify debugging, set the "Blocking" property on RtcHttpClient component to TRUE and make sure the MultiThreaded property is FALSE.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 23, 2013, 08:23:46 PM
Nope, Danijel,

I compiled both the fmx2AppServer and Client, works on Windows. And further created an Android App, copy all components, code, events, etc to the Android device. Made sure all the events are linked and components are set as good. Pointing to the running frm2AppServer at 192.168.0.235, port 8080 as usual. Somehow still doesn't work. Cannot connect. Tried client in blocking mode with multi-tasking too. Any idea?

Thanks,

Jim


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 23, 2013, 08:43:36 PM
And I run windows version fmx2AppClient on other PC over the network, works too. So it's not the server or network side for sure.

Thanks,


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 23, 2013, 09:00:35 PM
Well ... these same Projects worked on my Kindle Fire HD (Android device), and (as you can see) other developers have reported that they got their Project(s) working on Android too, so I can not say why it does not work on yours.

You've said that you are using Port 8080 on the Server. Have you tried using Port 80?

Have you tried running the File_Client Project (also in the SDKDemos_FMX2 group) without modifications and send requests to Web Servers over the Internet? With that Demo, you should not have to make any changes. Just build it, deploy it to your Android device and click "POST".

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 23, 2013, 09:40:09 PM
Are you using "Build" before you deploy the Project to the Android device? If you use "Compile", Delphi will be using old DCU files and these won't work. You need to use "Build" every time when working on multiple platforms, to ensure that all the files will be recompiled.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 23, 2013, 10:40:21 PM
Thanks Danijel for the prompt responses,

I did "build", "build all", and I tried 80 before move to 8080. What I did was to use the RawTcpServer and Client components. Write('Time'), Write(TimeToStr(Now()), etc...

It works on Windows, but not on Android phone. I did receive "OnConnect" event though, but when I shutdown the server, did not see disconnect or error even firing up.
When call sender.Write('Time'); the server never see the message.

I know and see other developers got it working, but could not figure out what is it I am not doing or did wrong. I will try the fileserver demo later on.

Thanks,

Jim


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 23, 2013, 11:55:12 PM
TRtcTcpClient and TRtcTcpServer components require special handling to work on non-Windows platforms. You need to manually call "NeedMoreData" to signal the components when to start reading from the socket. Without that, you will never receive anything. But the fact that you did get the OnConnect event is a good sign, because it means the physical connection is working.

Have you tried using the File_Client FMX2 Demo Project from your Android device? Or ... did you try to create a very simple Client Project by following the Quick Start Client Lesson 1 and try accessing the index page of some Web Server on the Internet?

Have you tried running the same code on the Android simulator?

Is there any difference when running it with, or without a Debugger?

If you can not get it working by trial and error, the only thing I can suggest is to go into the code step-by-step as it executes and see where it stops working. Setting RtcHttpClient components Blocking property to True and MultiThreaded to False should eliminate the problem of switching between multiple threads, so you should be able to follow the code as it executed. You won't see exceptions raised if the problem is related to low-level APIs, but should get an error code from the low-level API, if there is a problem with the socket.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 24, 2013, 03:57:02 AM
Interesting enough. When I run the fmx2AppClient, when making connection and disconnections, fmx2AppServer see it. But when run flood test, nothing happens.

Thanks for the help, Danijel. I will run some more debugging tomorrow.

Jim


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 24, 2013, 10:53:08 AM
I've ran more different tests with Delphi XE5 Projects running on my Android Tablet and bumped into some problems with Access Violations, after which things just stopped working properly.

What I've found out so far, is that changing lines 130 and 132 in the "rtcTypes.pas" unit (Lib folder) to declare RtcIntPtr and RtcThrID types as NativeUInt for CPUARM instead of longword seems to have a positive effect for Android Apps (I did not get Access Violations in my tests after making these two changes) ...

{$ELSE}{$IFDEF CPUARM}
  // @exclude
  RtcIntPtr = NativeUInt;
  // Thread ID
  RtcThrID = NativeUInt;
{$ELSE}{$IFDEF FPC}

... but, since the nature of memory related problems is such that everything could be working without a single visible problem most of the time, but then things could just stop working for no apparent reason (or the App would start raising Access Violations at seemingly random ocasions), I can not say if that small change will have solved all possible issues with the new Mobile compiler in Delphi XE5.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 25, 2013, 05:30:57 AM
Works now! Turn AutoConnect On, and Connect first. Thanks Danijel.


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 25, 2013, 09:34:51 AM
Thanks for your feedback. I have released RTC SDK v6.24 (2013.Q3) now with the above changes applied to the rtcTypes.pas unit, so anyone who is reading this post only has to download the latest RTC SDK release to fix RTC-related AVs in Android Apps.

Best Regards,
Danijel Tkalcec


Title: Re: Delphi XE5 Android Support
Post by: jimwang on October 26, 2013, 06:33:17 AM
Thanks Danijel,

Having it working, I just bought a Samsumg mega, installed the test app. Works!


Title: Re: Delphi XE5 Android Support
Post by: D.Tkalcec (RTC) on October 26, 2013, 08:27:35 AM
Thank you for the feedback.

Should you encounter any problems, please let me know.

Best Regards,
Danijel Tkalcec