An issue in Androidapi.Sensor.pas referring to symbols introduced in SDK version 26 will cause an linking error when your app references SDK version 22
If you are building Android applications with C++Builder 10.3.3, you may encounter an error [ldandroid Error] “ld” exited with code 1. The same issue can appear with different symptoms for Delphi 10.3.3 when attempt to match symbol names (such as using a script to gain symbols from call stacks generated by third party call stack libraries on Android, such as Grijjy’s error reporting code) in Delphi, where you will also get a linker error.
The issue is caused by a few symbols in the Androidapi.Sensor.pas file only being introduced in Android SDK version 26, but your application will link against version 22 where those symbols are not present. To resolve the errors, just make a local copy of the unit and comment out the symbols.
- Find the C:\Program Files (x86)\Embarcadero\Studio\20.0\source\rtl\android\Androidapi.Sensor.pas and Androidapi.inc files (or the same file in your RAD Studio installation folder, if you installed to a different location.)
- Make a copy of them in your project’s source folder, and addAndroidapi.Sensor.pas only to your project. Androidapi.inc is required to build your local copy of Androidapi.Sensor.pas.
- Open the file and locate and comment out the declarations for the following symbols:
- Ensure that when you upgrade to the next version, you remove your local copy of this file from your projects.
Brian Long kindly wrote up a longer article about the issue and workaround. Thanks Brian!