Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build ofxLua on Android Studio #54

Closed
cuinjune opened this issue Jun 13, 2019 · 4 comments
Closed

Cannot build ofxLua on Android Studio #54

cuinjune opened this issue Jun 13, 2019 · 4 comments

Comments

@cuinjune
Copy link

I can build an empty OF project without problems but when I add ofxLua, I cannot build the project. (I used Project Generator to create a project)

Here's the screenshot of errors I get:
Screen Shot 2019-06-13 at 10 54 03 PM

Any advice or guidance would be greatly appreciated.

@cuinjune
Copy link
Author

I figured out how to fix this error.

Add the following code in ofxLua/libs/lua/luaconf.h file: (e.g. in line 75)

#if defined(LUA_USE_ANDROID)
#include <android/log.h>
#define lua_getlocaledecpoint()    '.'
#define lua_writestring(s,l)        __android_log_write(ANDROID_LOG_DEBUG, "LUA_PRINT", (s))
#define lua_writeline()             __android_log_write(ANDROID_LOG_DEBUG, "LUA_PRINT", "\n")
#define lua_writestringerror(s,p)   __android_log_print(ANDROID_LOG_ERROR, "LUA_PRINT", (s), (p))
#endif

And add the followings in ofxLua/addon_config.mk

android/armeabi:
	ADDON_CFLAGS += -DLUA_USE_ANDROID
	ADDON_SOURCES_EXCLUDE += src/bindings/desktop/% src/bindings/linuxarm/%
	ADDON_INCLUDES_EXCLUDE += src/bindings/desktop/% src/bindings/linuxarm/%

android/armeabi-v7a:	
	ADDON_CFLAGS += -DLUA_USE_ANDROID
	ADDON_SOURCES_EXCLUDE += src/bindings/desktop/% src/bindings/linuxarm/%
	ADDON_INCLUDES_EXCLUDE += src/bindings/desktop/% src/bindings/linuxarm/%

In Android Studio, the exclude flags had no effect on the project (maybe a bug) so I had to manually remove the 2 folders (desktop, linuxarm) from ofxLua/src/bindings directory.

Also, to make Android Studio read the C flags from the addon_config.mk file, I had to add the following code below cppFlags.addAll(addonCppFlags(abi, ofRoot())) in build.gradle file.

  • CFlags.addAll(addonCppFlags(abi, ofRoot()))

After the fix, I could successfully build and run ofxLua project on an Android device.

@danomatika
Copy link
Owner

danomatika commented Dec 11, 2020

I've rolled your suggestions into the feature/android branch. Can you check that it builds for Android? The AS project fix steps are included in the readme.

Also, if those project issues are related to the OF ProjecGenerator, I suggest opening an issue with the OF PG repo.

@danomatika
Copy link
Owner

Closing for now.

@danomatika
Copy link
Owner

The feature/android branch is merged now. Please test it when you can and we can go from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants