Page 1 of 1

create log on android

Posted: Sun Mar 17, 2019 4:33 pm
by pedrox
In my engine I have created a function that prints a log file, the log file is created in the same folder in which the engine is located. Everything is working correctly.

Where I really want to try this log is about a gui on android, I have tried to create a file in the internal memory or the sd card giving it a full path because I think that in android it is necessary to specify complete paths. But the file is not created. I believe that I do not have writing permission.

I've only found information for java. Is it possible to do it with C language ?, the engines in android use log?

Thx

Re: create log on android

Posted: Sun Mar 17, 2019 10:15 pm
by Ras
If the directory the engine is in doesn't allow write access, then you can't create files there. This behaviour is the same under any Linux, not just Android. So the first thing is checking what the file permissions for this directory are.

Re: create log on android

Posted: Mon Mar 18, 2019 8:47 pm
by RĂ©mi Coulom
Is your engine compiled with the NDK?

The Android way of writing logs is to use the log native API:
https://developer.android.com/ndk/refer ... up/logging

I have code like this in my program:

Code: Select all

#ifdef __ANDROID__
#include <android/log.h>
#define LOG(x) do {\
 std::ostringstream oss;\
 oss << x;\
 __android_log_write(ANDROID_LOG_DEBUG, "my_program", oss.str().c_str());\
} while(false)
#endif

Re: create log on android

Posted: Tue Mar 19, 2019 7:11 pm
by pedrox
I use CodeSourcery ARM on Windows to compile the engine, maybe I should think about using the NDK since CodeSourcery is no longer free and I'm not sure if continued for Android.