Segmentation fault on startup in Delphi XE6 Firemonkey application for Android

 Android, Delphi  Comments Off on Segmentation fault on startup in Delphi XE6 Firemonkey application for Android
May 292014
 

After I attended the Delphi Power Workshop on mobile development with Delphi XE6 in Essen last week, the mobile development virus has taken hold of me. So I tried successfully to compile the demo apps for both, my Nexus 7 tablet and my Samsung Galaxy Note (GT-N7000) smartphone. That these worked out of the box got me hooked even more.

So, now I am writing my first useful App which is going to be a simple random number generator emulating the various dices used in games (In German dice is “Würfel” and there are several standard ones called W4, W6 (that’s the most widely used one), W8, W10, W12 and W20. My App is going to support these and in addition a custom one.

But back to the topic. I created a new “Firemonkey mobile Application” with a simple form, added a few controls and events and tried to run it on my smartphone. It immediately crashed with a segmentation fault in TFormBorder.GetSupported (unit FMX.Forms). Segmentation fault is the Android (Linux) equivalent of an Access Violation on Windows, most likely caused by referencing a NIL pointer. Being new to Android and Firemonkey development, I was expecting some very simple but hard to trace cause for this, like forgetting to call some initialization function I didn’t know about.

First thing I did was typing the error message and the method name into Google, but nothing turned up. Apparently I was the first one who had encountered that problem and talked about it.

So next I put a breakpoint into the method and checked the variables. As expected, there was a NIL pointer: Self was NIL. I traced back up the call stack and found that apparently the form’s ResizeHandle method was called before the form was properly instantiated. Then it dawned to me. I had made one of the most basic mistake in Delphi development: I had forgotten to call inherited Create in the form’s constructor.

So, even an old hand (or old fart, if you prefer that) in Delphi development can make basic mistakes. Also, what was wrong in Delph 1 in 1995 is still wrong in Delphi XE6 in 2014.

After I fixed this problem, everything works as expected.

Install Delphi Packages from commandline

 Delphi  Comments Off on Install Delphi Packages from commandline
May 112014
 

After I had to install the gazillion jvcl packages into my Delphi IDE manually again (Yes, I know it comes with an installer, I have got my reasons not to use it.), I finally grew tired of this and wrote this tool:

dzPackageInst is a command line program for installing designtime packages into Delphi IDEs. It supports Delphi 6 up to Delphi XE6.

Example:

dzpackageinst --delphiversion=7 dcltdbf70.bpl

Installs the tdbf design time package for Delphi 7 into the ide.

It can also uninstall packages:

dzpackageinst --uninstall --delphiversion=7 dcltdbf70.bpl

And if the package uses the default naming convention, that is a suffix that corresponds to the compiler version, it can guess the Delphi version to which the package belongs, so this will also work:

dzpackageinst dcltdbf70.bpl

That’s it. (If you want more functionality, there is a similar tool called Delphi Package Installer which has a lot more features.)

You can find the sources (Delphi 2007) for dzPackageInst in the mercurial repository on SourceForge. Note that you will also need the required libraries:

A pre built executable is also available