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.

Workaround

  1. 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.)
  2. 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.
  3. Open the file and locate and comment out the declarations for the following symbols:
    1. ASensorManager_getInstanceForPackage
    2. ASensorManager_getDefaultSensorEx
    3. ASensorManager_createSharedMemoryDirectChannel
    4. ASensorManager_createHardwareBufferDirectChannel
    5. ASensorManager_destroyDirectChannel
    6. ASensorManager_configureDirectReport
    7. ASensorEventQueue_registerSensor
    8. ASensor_isDirectChannelTypeSupported
    9. ASensor_getHighestDirectReportRateLevel
  4. Ensure that when you upgrade to the next version, you remove your local copy of this file from your projects.

Writeup

Brian Long kindly wrote up a longer article about the issue and workaround. Thanks Brian!

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.

Start Free Trial   Free Delphi Community Edition   Free C++Builder Community Edition   Upgrade Today