Fix "Jar libraries added to Android 64-bit platform target are not compiled"
Due to a bug (as at March 28th, 2023) in Delphi 11.3, libraries that are added to the Android 64-bit platform target in a project are not compiled. This can result in errors when the application runs, e.g:
Project testapp.apk raised exception class EJNIFatal with message
'Java type com/delphiworlds/kastri/DWAdListenerDelegate could not be found'.
Previously, libraries that were added to Android 32-bit platform target were also compiled when targeting Android 64-bit.
The following steps fix the issue for all projects (see below for an alternate solution, which works on a project-by-project basis):
- Make a backup of the
CodeGear.Common.Targetsfile in thebinfolder of your Delphi install - Make another copy of the same file in a folder where it can be edited
- At line 958 in the file, there is this section:
<!-- Return all the customized .jar files included on the project -->
<Target Name="GetProjectJars">
<ItemGroup>
<_JarsLocations Include="%(JavaReference.FullPath)" Condition="('%(JavaReference.Disabled)'!='True') And ('%(JavaReference.IsSystem)'!='True') And
(('$(Platform)'=='$(cAndroidArm64Platform)' And '%(JavaReference.ContainerId)'=='ClassesdexFile64') Or
('$(Platform)'=='$(cAndroidArm32Platform)' And '%(JavaReference.ContainerId)'=='ClassesdexFile')
)">
<PredexedJar>$(OutputClassesDexDir)%(JavaReference.Filename)$(PredexedJarSuffix)%(JavaReference.Extension)</PredexedJar>
</_JarsLocations>
</ItemGroup>
</Target>
Modify the section to look like this:
<!-- Return all the customized .jar files included on the project -->
<Target Name="GetProjectJars">
<ItemGroup>
<_JarsLocations Include="%(JavaReference.FullPath)" Condition="('%(JavaReference.Disabled)'!='True') And ('%(JavaReference.IsSystem)'!='True')">
<PredexedJar>$(OutputClassesDexDir)%(JavaReference.Filename)$(PredexedJarSuffix)%(JavaReference.Extension)</PredexedJar>
</_JarsLocations>
</ItemGroup>
</Target>
- Copy the modified
CodeGear.Common.Targetsfile to thebinfolder in your Delphi install
The following steps is the "official" workaround, however this works only on a project-by-project basis (which means you will need to update your existing projects if you compile for Android 64-bit):
- Make a copy of the
jarfiles that you have added to the project, and copy them to a separate folder. - Add the copies of the
jarfiles to the Libraries node of the Android 64-bit target platform in Project Manager