[Lazarus] android: debugln and thread

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Thu May 9 12:09:47 CEST 2013


I suppose you are talking about native code and LCL-CustomDrawn in
Android, correct?

The source code for DebugLn in Android is located in
lcl/interfaces/customdrawn/customdrawnobject_android.inc

procedure TCDWidgetSet.AndroidDebugLn(ASender: TObject; AStr: string;
var AHandled: Boolean;
  Target: TLazLoggerWriteTarget; Data: Pointer);
begin
  AHandled := Target in [lwtStdOut, lwtStdErr];
  if not AHandled then exit;
  __android_log_write(ANDROID_LOG_INFO, 'lclapp', PChar(AccumulatedStr+AStr));
  AccumulatedStr := '';
end;

So I suppose that FPC threading breaks __android_log_write. Try using
__android_log_write directly instead of DebugLn to be 100% sure.
Notice that __android_log_write is a NDK function, it is part of the
Android NDK released by Google, it is not our code.

Try asking in the android-ndk Google Groups about the problem. Google
engineers there helped me with problems.

One idea would be to try to see if creating a thread using pthreads
directly would also break __android_log_write... I never created a
thread this way, so I have no idea how to do it, but Google shows many
pthreads tutorials. I suppose that Android uses pthreads, but could be
wrong.

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list