cnlohr / rawdrawandroid

Build android apps without any java, entirely in C and Make
MIT License
3.55k stars 226 forks source link

App flashes quickly when trying to open it (dlopen failed: cannot locate symbol "example_log_function") #81

Closed jiura closed 9 months ago

jiura commented 9 months ago

Hey there, great project. I tested it by cloning the repo first and got it to work fine. Then I tried making my own project using rawdrawandroid as a submodule and when the app installs it flashes quickly and closes every time I try to open it.

By running adb logcat | grep UnsatisfiedLinkError I managed to get the following error:

E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/org.inloco.Funcional-qlzudJ1NlM5TiULMRAIWLA==/lib/arm64/libFuncional.so": dlopen failed: cannot locate symbol "example_log_function" referenced by "/data/app/org.inloco.Funcional-qlzudJ1NlM5TiULMRAIWLA==/lib/arm64/libFuncional.so"...

There's an old closed issue where some other guy had apparently the same problem I do, but I didn't see anything helpful there.

Is there any way you can help me, please? I've already checked that the include paths are correctly set in the makefile even though I'm calling make from one directory up rawdrawandroid, so I'm really at a loss, especially since I have no idea where "example_log_function" is from.

dreua commented 9 months ago

Hi, unfortunately I'm not sure if anyone is currently working with this project and able to help you out. You might have a look into the discord server, sometimes there is more activity there than here.

I found some instances of the function when searching in other projects: https://github.com/search?q=org%3Acnlohr+example_log_function&type=code

jiura commented 9 months ago

I see, thank you for the info. I'll look around a bit in these projects you linked and if I do find any solution I'll comment it here. Otherwise, I'll try the discord. Thanks again.

jiura commented 9 months ago

Managed to fix it, I messed up with the Makefile one folder up rawdrawandroid submodule. I copied the one in https://github.com/cnlohr/rawdrawandroidexample and made some changes, but was using the test.c in this repository here (rawdrawandroid) instead of the one in rawdrawandroidexample, since that one seems to be pretty old.

So the problem was at line 3 of the rawdrawandroidexample Makefile:

CFLAGS:=-I. -ffunction-sections -Os -fvisibility=hidden -DRDALOGFNCB=example_log_function

That macro definition -DRDALOGFNCB=example_log_function was looking for a function that didn't exist in my test.c, so all I had to do was take it out of there. Not sure what kind of logs it was responsible for and too lazy to check it right now though.

Thanks again @dreua for pointing out where example_log_function was.