Wrap existing 3rd party SDK for Android into a Corona plugin

Hello,

I have an SDK that I need to integrate into my game. It is an Android Library Project type of library.

ZIP archive with the library attached. It has files

AndroidManifest.xml

project.properties

libs/GiftizSDK_1.5.0.jar

res/ with many graphical and xml files

I’ve followed quickstart guide and can compile blank plugin.

What do I do next?

http://developer.android.com/tools/projects/projects-cmdline.html#ReferencingLibraryProject

Okay. This is not easy, but I’ve learn’t many new things.

What I’ve tried:

Link the Project Library using

android.library.reference.1=…/GiftizSDKLibrary

Update it with

android update lib-project --target “android-16” --path .

Create empty /src directory

At this point I can run ./build.plugin.sh and it gets build without errors

I’ve tried integrating it using self-hosted plugin method with no luck.

Then from Sean I learn that I simply can’t use Library Projects this way because they have their own res/ files.

Second Way:

Now simply put GiftizSDK_1.5.0.jar inside android/libs directory.

I remove <delete dir=“libs”/> from build.plugin.xml so my JAR doesn’t get removed when I try to build the plugin.

Now I can build the resulting plugin.giftiz.jar file.

I create metadata.lua saying that this is a jar plugin.

I make a TGZ archive of these two files and upload it to my dropbox.

I edit my build.settings

[‘plugin.giftiz’] = {publisherId = ‘com.giftiz’, supportedPlatforms = {android = {url = 'http://dl.dropboxusercontent.com/u/55969280/plugin.giftiz.tgz’}}}

I know I lack /res files for the SDK, but I want to just use non graphical features of it right now.

Building APK is fine. Running on a device. require(‘plugin.giftiz’) works.

But invoking any method of GiftizSDK class is causing a runtime error:

I/Corona  ( 6543): Runtime error

I/Corona  ( 6543): java.lang.NoClassDefFoundError: com.purplebrain.giftiz.sdk.GiftizSDK

I/Corona  ( 6543): Java Stack Trace:

I/Corona  ( 6543): plugin.giftiz.LuaLoader.missionComplete(LuaLoader.java:189)

I/Corona  ( 6543): plugin.giftiz.LuaLoader$MissionCompleteWrapper.invoke(LuaLoader.java:240)

I/Corona  ( 6543): com.ansca.corona.JavaToNativeShim.nativeTouchEvent(Native Method)

I/Corona  ( 6543): com.ansca.corona.JavaToNativeShim.touchEvent(JavaToNativeShim.java:413)

I/Corona  ( 6543): com.ansca.corona.input.RaiseTouchEventTask.executeUsing(RaiseTouchEventTask.java:39)

I/Corona  ( 6543): com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)

I/Corona  ( 6543): com.ansca.corona.events.EventManager.sendEvents(EventManager.java:87)

I/Corona  ( 6543): com.ansca.corona.Controller.updateRuntimeState(Controller.java:281)

I/Corona  ( 6543): com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

I/Corona  ( 6543): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

I/Corona  ( 6543): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

I/Corona  ( 6543): stack traceback:

I/Corona  ( 6543): [C]: in funct

W/dalvikvm( 6543): threadid=10: thread exiting with uncaught exception (group=0x41a6ed40)

E/AndroidRuntime( 6543): FATAL EXCEPTION: GLThread 492

E/AndroidRuntime( 6543): Process: com.spiralcodestudio.hexled, PID: 6543

E/AndroidRuntime( 6543): java.lang.NoClassDefFoundError: com.purplebrain.giftiz.sdk.GiftizSDK

E/AndroidRuntime( 6543): at plugin.giftiz.LuaLoader.onSuspended(LuaLoader.java:122)

E/AndroidRuntime( 6543): at com.ansca.corona.CoronaEnvironment$RuntimeEventHandler.onSuspended(CoronaEnvironment.java:446)

E/AndroidRuntime( 6543): at com.ansca.corona.CoronaRuntime.onSuspended(CoronaRuntime.java:382)

E/AndroidRuntime( 6543): at com.ansca.corona.NativeToJavaBridge.callOnRuntimeSuspended(NativeToJavaBridge.java:426)

E/AndroidRuntime( 6543): at com.ansca.corona.JavaToNativeShim.nativePause(Native Method)

E/AndroidRuntime( 6543): at com.ansca.corona.JavaToNativeShim.pause(JavaToNativeShim.java:143)

E/AndroidRuntime( 6543): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:286)

E/AndroidRuntime( 6543): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

E/AndroidRuntime( 6543): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

E/AndroidRuntime( 6543): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

W/ActivityManager( 1024):   Force finishing activity com.spiralcodestudio.hexled/com.ansca.corona.CoronaActivity

Looks like original JAR from Giftiz is not getting into the APK somehow.

And it seems like there are no more options and I have to use normal Enterprise way for this to work. Without any plugins.

You should try putting the GiftizSDK_1.5.0.jar into the tarball.  The plugin.giftiz.jar file you have in your tarball does not have the SDK’s code.

@dchan, wow, looks line now it actually works! Thank you.

I’ll try to resolve issue with res/ with help of Giftiz developers.

http://developer.android.com/tools/projects/projects-cmdline.html#ReferencingLibraryProject

Okay. This is not easy, but I’ve learn’t many new things.

What I’ve tried:

Link the Project Library using

android.library.reference.1=…/GiftizSDKLibrary

Update it with

android update lib-project --target “android-16” --path .

Create empty /src directory

At this point I can run ./build.plugin.sh and it gets build without errors

I’ve tried integrating it using self-hosted plugin method with no luck.

Then from Sean I learn that I simply can’t use Library Projects this way because they have their own res/ files.

Second Way:

Now simply put GiftizSDK_1.5.0.jar inside android/libs directory.

I remove <delete dir=“libs”/> from build.plugin.xml so my JAR doesn’t get removed when I try to build the plugin.

Now I can build the resulting plugin.giftiz.jar file.

I create metadata.lua saying that this is a jar plugin.

I make a TGZ archive of these two files and upload it to my dropbox.

I edit my build.settings

[‘plugin.giftiz’] = {publisherId = ‘com.giftiz’, supportedPlatforms = {android = {url = 'http://dl.dropboxusercontent.com/u/55969280/plugin.giftiz.tgz’}}}

I know I lack /res files for the SDK, but I want to just use non graphical features of it right now.

Building APK is fine. Running on a device. require(‘plugin.giftiz’) works.

But invoking any method of GiftizSDK class is causing a runtime error:

I/Corona  ( 6543): Runtime error

I/Corona  ( 6543): java.lang.NoClassDefFoundError: com.purplebrain.giftiz.sdk.GiftizSDK

I/Corona  ( 6543): Java Stack Trace:

I/Corona  ( 6543): plugin.giftiz.LuaLoader.missionComplete(LuaLoader.java:189)

I/Corona  ( 6543): plugin.giftiz.LuaLoader$MissionCompleteWrapper.invoke(LuaLoader.java:240)

I/Corona  ( 6543): com.ansca.corona.JavaToNativeShim.nativeTouchEvent(Native Method)

I/Corona  ( 6543): com.ansca.corona.JavaToNativeShim.touchEvent(JavaToNativeShim.java:413)

I/Corona  ( 6543): com.ansca.corona.input.RaiseTouchEventTask.executeUsing(RaiseTouchEventTask.java:39)

I/Corona  ( 6543): com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)

I/Corona  ( 6543): com.ansca.corona.events.EventManager.sendEvents(EventManager.java:87)

I/Corona  ( 6543): com.ansca.corona.Controller.updateRuntimeState(Controller.java:281)

I/Corona  ( 6543): com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

I/Corona  ( 6543): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

I/Corona  ( 6543): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

I/Corona  ( 6543): stack traceback:

I/Corona  ( 6543): [C]: in funct

W/dalvikvm( 6543): threadid=10: thread exiting with uncaught exception (group=0x41a6ed40)

E/AndroidRuntime( 6543): FATAL EXCEPTION: GLThread 492

E/AndroidRuntime( 6543): Process: com.spiralcodestudio.hexled, PID: 6543

E/AndroidRuntime( 6543): java.lang.NoClassDefFoundError: com.purplebrain.giftiz.sdk.GiftizSDK

E/AndroidRuntime( 6543): at plugin.giftiz.LuaLoader.onSuspended(LuaLoader.java:122)

E/AndroidRuntime( 6543): at com.ansca.corona.CoronaEnvironment$RuntimeEventHandler.onSuspended(CoronaEnvironment.java:446)

E/AndroidRuntime( 6543): at com.ansca.corona.CoronaRuntime.onSuspended(CoronaRuntime.java:382)

E/AndroidRuntime( 6543): at com.ansca.corona.NativeToJavaBridge.callOnRuntimeSuspended(NativeToJavaBridge.java:426)

E/AndroidRuntime( 6543): at com.ansca.corona.JavaToNativeShim.nativePause(Native Method)

E/AndroidRuntime( 6543): at com.ansca.corona.JavaToNativeShim.pause(JavaToNativeShim.java:143)

E/AndroidRuntime( 6543): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:286)

E/AndroidRuntime( 6543): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

E/AndroidRuntime( 6543): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

E/AndroidRuntime( 6543): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

W/ActivityManager( 1024):   Force finishing activity com.spiralcodestudio.hexled/com.ansca.corona.CoronaActivity

Looks like original JAR from Giftiz is not getting into the APK somehow.

And it seems like there are no more options and I have to use normal Enterprise way for this to work. Without any plugins.

You should try putting the GiftizSDK_1.5.0.jar into the tarball.  The plugin.giftiz.jar file you have in your tarball does not have the SDK’s code.

@dchan, wow, looks line now it actually works! Thank you.

I’ll try to resolve issue with res/ with help of Giftiz developers.