Accessing NMEA on Android API level < 24 when compiled for target API level 29?

It seems there was a problem in the Android SDK 29 release and the method providing retro-compatibility was left out.

There is an issue opened in the Android bugtracker

From the comments of the Android engineers in that issue, the recommended approach is to access it via reflection... I still have to test it, but I guess it would be on the line of the following:

nmeaListenerDeprecated = new GpsStatus.NmeaListener() {
    @Override
    public void onNmeaReceived(long timestamp, String message) {
        // TODO
    }
};
try {
    //noinspection JavaReflectionMemberAccess
    Method addNmeaListener =
        LocationManager.class.getMethod("addNmeaListener", GpsStatus.NmeaListener.class);
    addNmeaListener.invoke(locationManager, nmeaListenerDeprecated);
} catch (Exception exception) {
    // TODO
}

EDIT: there was a missing argument in the .invoke() call. It needs the target object reference to perform the invocation! (too long since learning Reflection... and not used it ever since!)