Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Cannot compile Android plugin — Gideros Forum

Cannot compile Android plugin

amaximovamaximov Member
edited February 2014 in General questions
I've been trying to make a plugin to access device identifiers and finished iOS plugin really fast, but Android has been a struggle for several hours. I followed @ar2rsawseen 's tutorial on AppCodingEasy but was not able to get things to work properly. I then looked at the plugin sources in the Gideros installation and did some minor tweaks to my identifier.cpp but still got NDK errors (Attached).

Here is my bare-bones attempt at just getting a successful build.
identifier.cpp:

#include "gideros.h"
#include "lua.h"
#include "lauxlib.h"

static const char* pluginName = "identifier";
static const char* pluginVersion = "1.0";
/*static const char* javaClassName = "com/giderosmobile/android/ExamplePlugin";

// Store Java Environment reference
static JNIEnv *ENV;
// Store our main class, what we will use as plugin
static jclass cls;*/

// Here we register all functions we could call from lua
static const struct luaL_Reg funcs[] = {
{ NULL, NULL } //Don't forget nulls at the end
};

// Here we register all the C functions for lua so lua engine would know they exists
static int luaopen_plugin(lua_State *L)
{
luaL_register(L, pluginName, funcs);
return 1;
}

//here we do all our stuff needs to be done on initialization
static void g_initializePlugin(lua_State *L)
{
// Get java environment reference
//ENV = g_getJNIEnv();

// Get global package object
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");

// Put our plugin name inside with a callback to registering C functions
lua_pushcfunction(L, luaopen_plugin);
lua_setfield(L, -2, pluginName);

lua_pop(L, 2);
}

// And here we free everything we need to free
static void g_deinitializePlugin(lua_State *L)
{

}

// Register our plugin with Gideros lib
REGISTER_PLUGIN(pluginName, pluginVersion)

Android.mk:

LOCAL_PATH := $(call my-dir)

###

include $(CLEAR_VARS)

LOCAL_MODULE := lua
LOCAL_SRC_FILES := ../../libs/$(TARGET_ARCH_ABI)/liblua.so

include $(PREBUILT_SHARED_LIBRARY)

###

include $(CLEAR_VARS)

LOCAL_MODULE := gideros
LOCAL_SRC_FILES := ../../libs/$(TARGET_ARCH_ABI)/libgideros.so

include $(PREBUILT_SHARED_LIBRARY)

###

include $(CLEAR_VARS)

LOCAL_MODULE := identifier
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -O2
LOCAL_SRC_FILES := identifier.cpp
LOCAL_LDLIBS := -ldl -llog
LOCAL_SHARED_LIBRARIES := gideros

include $(BUILD_SHARED_LIBRARY)


Capture.PNG
1132 x 139 - 22K

Comments

Sign In or Register to comment.