This is the blog of Brian Long, Windows & mobile trainer, trouble-shooter and consultant.
Friday, 14 February 2020
25 Delphi Tips for 25 Years of Delphi
As it happens I've been part of the Delphi world for around 26 years now, as I used to work at Borland and was involved with testing and experimenting with and working with the pre-release versions.
What can I say other than Happy Birthday, Delphi? You've been a good friend to me over this last quarter of a century and I've been happy to be part of your world.
Some number of posts ago I wrote up 10 Tips for Delphi Users. When I checked I was horrified to find this was 7 years ago! (My, my, how time flies when you're having fun...) Anyway, I thought I'd take that list and build upon it, expanding it up to 25 tips for Delphi users, which is what we have here. So without further ado let's get straight into the list.
Wednesday, 12 February 2020
The Enter key and the OnKeyDown/OnKeyUp events on Android
OnKeyDown and OnKeyUp events. This was unfortunate as Tom wanted to code to run in (one of) those handlers.The problem had been reported as RSP-27496 but alas it had been closed at the time Tom was hunting for a solution (to my mind closed wrongly).
What to do?
Well, after some valiant fighting with the problem accompanied with the inevitable wailing and gnashing of teeth, Tom found a workaround of sorts. Setting the
TEdit control's ReturnKeyType property Go, Search or Send allows the OnKeyDown event to fire for the Enter key. Good stuff! But not ideal....I sent a note to a relevant party within EMBT and after reviewing the report it has since been re-opened. That's a start.
Tuesday, 11 February 2020
C++Builder's Android location sensor woes
If you make a new Multi-Device Application in C++Builder and build it, all will be well, of course. The basics work very nicely.
If you now drop a
TLocationSensor component on the form and try to build now, the result will be different. Compilation goes fine. Linking looks like it is going fine.... until it fails with a rather unhelpful message:[ldandroid Error] "ld" exited with code 1.
Let's look at how we can get more useful feedback from this rather opaque and somewhat 1990s error message and see how to resolve the underlying problem.
Rebuilding the Delphi & C++Builder Android Java files
The script would rebuild all the Java files into the required fmx.dex.jar and fmx.jar archives and copy them into the relevant RAD Studio installation folders to be used on subsequent builds.
When I tried to use the script with RAD Studio 10.3.3 of course it didn't work as things have changed, different files need to be involved in the process. I have updated the script now to work with RAD Studio 10.3.3 and thought I'd share it in case anyone else needs to do this.
An obvious question is: Why would anyone else want to rebuild the Java Android RTL files? Well this is normally a necessary step if you find an issue in the code as Embarcadero ships it and you want to try to fix it or enhance it. Indeed the previous post on rebuilding the 10.3 Java files was all about patching the Java code to get Android
Intent support working.If you have no interest in tweaking the Java code or fixing any issues you encounter in the Java code then you probably won't be needing this script.
If you do need the script, remember to take a backup of your original compiled archives before you proceed. These are found in:
- C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\debug\fmx.jar
- C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\debug\fmx.dex.jar
- C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\release\fmx.jar
- C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\release\fmx.dex.jar
The script needs to be run from an administrative command prompt and before you run it you should double-check the various paths set up in the environment variables at the start are all valid on your system.
Tuesday, 8 January 2019
Solution to iOS Delphi build failure
Some Delphi users building iOS applications have been thwarted by a…, well let’s be polite and call it a bit of an annoyance, when building their applications. What should just be an informational message about a warning from the ld linker ends up becoming a build breaker. The failure message looks something like this example (taken from RSP-19759, reported in January 2018):
[DCC Error] E2597 ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFFCEE7) is
too big in FBSDKShareKit.a(FBSDKAppInviteContent.o) ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF6E38) is too big
in C:\Dev\lib\ios\facebook\FBSDKShareKit.framework\FBSDKShareKit.a
(FBSDKAppInviteContent.o)
The fact that ld is emitting a warning about something is neither here not there. Or rather it *should* be neither here nor there. Unfortunately when Delphi receives this warning it turns it into a fatal error.
Oh dear… (・_・、)
Delphi 10.3 Rio contains a change to address this issue…. ˚◡˚
Unfortunately, however, Embarcadero forgot to mention it to anyone ¯\_(ツ)_/¯
This post tries to fix that communications oversight by covering the details of the change, which is an important step as you do need to add in a new compiler / linker switch.
The iOS ld linker now supports a new option –bequiet, which stops Delphi being able to wrongly interpret the ld warnings (by silencing them).
To use the new option choose Project | Options… (Shift+Ctrl+F11) and do one of these two things:
- select Building | Delphi Compiler | Compiling | Other Options and add
--linker-option:-bequietto Additional options to pass to the compiler, or - select Building | Delphi Compiler | Linking and add -bequiet to Options passed to the LD linker
You should now be able to build your project successfully without this little hindrance.
Good luck!
Saturday, 8 December 2018
CodeRage 2018 (redux)
This year at CodeRage 2018 I presented a session on Creative Delphi Debugging Techniques.
Other than my speaking volume being a bit quiet, it generated a number of very nice comments about the subjects covered so I thought it might be useful to mention that it is available for on-demand viewing as part of the CodeRage 2018 Replay.
There is free enrolment in the conference replay and my session, along with the session slides and sample files, can be found here.
If you watch it I hope you turn up your PC volume and get a lot out of it to hopefully help with your debugging exercises!
RAD Studio 10.3 Rio’s Android Intent support (or current lack thereof)
Sometimes when a new product is released there are a few ‘teething issues’. That certainly seems to be the case with RAD Studio 10.3 Rio. Both Delphi and C++Builder are hitting a few problems on various fronts. Now, it is true that internally in the product there has been a lot of change in the IDE, the VCL and FireMonkey, and perhaps it is therefore unsurprising a few slip-ups will have occurred.
It is, however, quite annoying when you fall foul of these slip-ups and have to wait for a fix….
The issue I want to address in this post is the breakage in the Android support for registering an interest in knowing about certain Intent objects received by the app. This is normally achieved by a call to MainActivity.registerIntentAction, as pseudo-documented here (when it was introduced in RAD Studio 10 Seattle) and here (in reference to a sample app) on Embarcadero's docwiki and illustrated here in my article on NFC usage.
This new Intent support worked nicely in RAD Studio 10 Seattle, 10.1 Berlin and 10.2 Tokyo. Not so in RAD Studio 10.3 Rio. You get a crash when trying to register a new Intent that you want to act upon.