Upgrade Your Projects With These Tips And Tricks For Firemonkey In Delphi 10 Seattle

If you are upgrading your projects from previous versions of Delphi Firemonkey like XE5, XE6, XE7, and XE8 to Firemonkey in Delphi 10 Seattle here are some tips and tricks which may help you. There are less refactoring changes in the FMX RTL between XE8 and Seattle as far as I’ve seen so upgrading should go pretty smoothly. These tips cover upgrading older projects so that they compile and run on the latest version and patching some components which may not be available yet for the latest version.

Upgrading XE5, XE6, and XE7 Projects

If you are upgrading a project from XE5, XE6, or XE7 to Delphi 10 Seattle what you may want to do is create a new project file instead and then click Project|Add To Project in the IDE. Add all of the old forms and units from your previous project to the new Delphi Seattle project. The reason for this is that XE8 introduced new mobile platforms and some older projects may not load correctly. Once you create the new project and add the original units it should work okay.

Upgrading Android Projects

If you are upgrading an XE5, XE6, XE7, or XE8 project which you have deployed to Android in the past you will want to delete any existing AndroidManifest.template.xml files that may be hanging around. The older Android manifest file will cause problems in the latest version (when you rotate the device the app will close). By deleting the old file a new file will automatically get created to replace it. If you modified your AndroidManifest.template.xml by adding an Android service, a custom DEX file, or push notifications you will need to add those modifications to the new AndroidManifest.template.xml file as well. Be aware that when you create a new project and have not yet saved it anywhere it will exist in My Documents\Embarcadero\Studio\Projects\ and there is a AndroidManifest.template.xml file there which should be deleted as well.

Upgrading Projects Using IJavaInterface

The IJavaInterface definition was removed from the RTL. If you have a project or component that uses it you will need to find a workaround. One project that uses it is the AerServ library. If you do encounter this error in AerServCommon.Android.pas one thing you can do is paste this code at the top of the file:

Delphi/Pascal

1

2

3

4

5

6

7

const

IID_IJavaInterface_Name=‘{024CE73D-3FF3-423B-B8B1-DCE9DAC254C6}’;

IID_IJavaInterface:TGUID=IID_IJavaInterface_Name;

type

IJavaInterface=interface(IJava)

[IID_IJavaInterface_Name]

end;

The AerServ library for Android should compile at this point. I have not tested any other compatibility issues with it so use at your own risk. There may also be a replacement for IJavaInterface that I am not aware of.

Upgrading PaxCompiler v4.2

If you are using paxCompiler v4.2 and would like to compile it in Delphi 10 Seattle you can paste this near the bottom of PaxCompiler.def (above the {$IFNDEF VARIANTS}{$DEFINE MSWINDOWS}{$ENDIF} section):

Delphi/Pascal

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

{$ifdef Ver300}

{$define VARIANTS}

{$define UNIC}

{$define DRTTI}

{$define DPULSAR}

{$define DXE7}

{$define GE_DXE2}

{$define GE_DXE3}

{$define GE_DXE4}

{$define GE_DXE5}

{$define GE_DXE6}

{$define GE_DXE7}

{$define GE_DXE8}

{$IFDEF CPUX64}

{$DEFINE PAX64}

{$ENDIF}

{$endif}

Upgrading TListView

TListView has been refactored in Delphi 10 Seattle. If you use any of it’s events which utilize TListViewItem you will need to add two additional includes into your unit. The two new units are FMX.ListView.Appearances and FMX.ListView.Adapters.Base. Alternately, you can delete the FMX.ListView and FMX.ListView.Types units from the Uses clause and it will automatically re-include all the needed units. If you previously used the TListView.Selected property you will need to change it to something like this instead ListView1.Items[ListView1.Selected.Index].

Upgrading AppTethering Projects

The way AppTethering works in Seattle has changed from XE8. The events for sending and receiving data are different so you may have to rework your code in those events completely to get it working again. There are AppTethering demos you can look at to see how the new events work. You can also review the AppTethering documentation. Be aware that AppTethering is not compatible between versions. XE7 AppTethering can not talk to XE8 AppTethering or to Delphi 10 AppTethering.

Manually Upgrading Third Party Delphi XE8 Components

If you are using some third party components or code and you can’t wait for the vendor to upgrade them you can always try patching them yourself. The main thing you can look for is code that uses {$ifdef Ver290}. That signifies a section of code that will run if it is compiled in Delphi XE8. You can duplicate that section and change the new piece of code to {$ifdef Ver300} which signifies Delphi 10 Seattle. In the PaxCompiler example above you can see where I did just that. Obviously this does not take into account any architecture changes in Delphi but may get you a head start in upgrading your projects that use third party components.

Utilizing Delphi Components In AppMethod

If you are using AppMethod and you would like to use some components which are for Delphi but do not mention Appmethod chances are they will just work. However, if you receive any error where it stops on you a Unit called VCL or something similar in it’s package file you should be able to remove this unit and the component should still compile. The component may not have full functionality at design time if there are any property editors but otherwise it should have full functionality.

Upgrading Android Services

If you rolled your own Android service capability with a previous version of Firemonkey you can now use the built in Android service functionality. You can read a tutorial for creating an Android service in Delphi 10 here.

Upgrading a VCL Project To FMX

Lastly if you have a VCL project and you would like to convert it to Firemonkey (and possibly mobile) there is always the Mida Converter utility. It will even convert and utilize some third party components. Read our coverage of Mida Converter.