OpenHome Forum
New to OhNet, need help - Printable Version

+- OpenHome Forum (http://forum.openhome.org)
+-- Forum: OpenHome (/forumdisplay.php?fid=1)
+--- Forum: Net (/forumdisplay.php?fid=5)
+--- Thread: New to OhNet, need help (/showthread.php?tid=1101)

Pages: 1 2


New to OhNet, need help - dcong - 01-03-2013 12:09 AM

Hi all,

I am new to OhNet, and would like to use it in an Android application.

I have already compiled and imported the library into my Android project, but have no idea where to start with.

Could any one please give me some advice or is there any sample code I can refer to?

Thanks,


RE: New to OhNet, need help - simonc - 01-03-2013 08:41 AM

(01-03-2013 12:09 AM)dcong Wrote:  I am new to OhNet, and would like to use it in an Android application.

I have already compiled and imported the library into my Android project, but have no idea where to start with.

Could any one please give me some advice or is there any sample code I can refer to?

You could start by reading the overview docs linked from http://www.openhome.org/wiki/OhNet. If you're writing an Android app, the Control Point docs are probably most relevant.

One of the Java tests - ohnet/OpenHome/net/Bindings/Java/org/openhome/net/controlpoint/tests/TestProxy.java - is a small control point app so would be a good sample / reference for you. See the API docs at the link above if the purpose of any of the library calls is unclear.


RE: New to OhNet, need help - dcong - 03-03-2013 01:31 AM

(01-03-2013 08:41 AM)simonc Wrote:  
(01-03-2013 12:09 AM)dcong Wrote:  I am new to OhNet, and would like to use it in an Android application.

I have already compiled and imported the library into my Android project, but have no idea where to start with.

Could any one please give me some advice or is there any sample code I can refer to?

You could start by reading the overview docs linked from http://www.openhome.org/wiki/OhNet. If you're writing an Android app, the Control Point docs are probably most relevant.

One of the Java tests - ohnet/OpenHome/net/Bindings/Java/org/openhome/net/controlpoint/tests/TestProxy.java - is a small control point app so would be a good sample / reference for you. See the API docs at the link above if the purpose of any of the library calls is unclear.

After compiling, I got ohnet.jar and imported it into Android project. But when I ran the program (just "Library l = new Library()"), it throws the exception of java.lang.NoClassDefFoundError: org.openhome.net.core.Library.

Any idea how it can be fixed?

Thanks


RE: New to OhNet, need help - simonc - 04-03-2013 03:08 PM

(03-03-2013 01:31 AM)dcong Wrote:  After compiling, I got ohnet.jar and imported it into Android project. But when I ran the program (just "Library l = new Library()"), it throws the exception of java.lang.NoClassDefFoundError: org.openhome.net.core.Library.

Any idea how it can be fixed?

ohNet is implemented in C++ with Java (and other language) bindings to its public APIs. This means that you need to deploy a couple of native libraries as well as the Java code. Can you check that libohNet.so and libohNetJni.so are available at the same location as the Java code please?


RE: New to OhNet, need help - dcong - 04-03-2013 06:04 PM

(04-03-2013 03:08 PM)simonc Wrote:  
(03-03-2013 01:31 AM)dcong Wrote:  After compiling, I got ohnet.jar and imported it into Android project. But when I ran the program (just "Library l = new Library()"), it throws the exception of java.lang.NoClassDefFoundError: org.openhome.net.core.Library.

Any idea how it can be fixed?

ohNet is implemented in C++ with Java (and other language) bindings to its public APIs. This means that you need to deploy a couple of native libraries as well as the Java code. Can you check that libohNet.so and libohNetJni.so are available at the same location as the Java code please?

I put libohNet.so and libohNetJni.so in libs/armeabi, and System.loadLibrary("libohNet/Jni.so") works fine.

Do you mean they should be put in the same dir?

Thanks


RE: New to OhNet, need help - simonc - 04-03-2013 06:26 PM

(04-03-2013 06:04 PM)dcong Wrote:  I put libohNet.so and libohNetJni.so in libs/armeabi, and System.loadLibrary("libohNet/Jni.so") works fine.

Do you mean they should be put in the same dir?

I don't know a great deal about Android building but would assume that any location that is acceptable to System.loadLibrary is fine.

It sounds like we'll need to try to reproduce your problem.

Are you using a binary release of ohNet or building it yourself? If you're using a binary release, can you confirm which one please? If you're building yourself, can you confirm the exact build environment & commands?


RE: New to OhNet, need help - dcong - 04-03-2013 06:43 PM

(04-03-2013 06:26 PM)simonc Wrote:  
(04-03-2013 06:04 PM)dcong Wrote:  I put libohNet.so and libohNetJni.so in libs/armeabi, and System.loadLibrary("libohNet/Jni.so") works fine.

Do you mean they should be put in the same dir?

I don't know a great deal about Android building but would assume that any location that is acceptable to System.loadLibrary is fine.

It sounds like we'll need to try to reproduce your problem.

Are you using a binary release of ohNet or building it yourself? If you're using a binary release, can you confirm which one please? If you're building yourself, can you confirm the exact build environment & commands?

I compiled it myself.

OS: i686-redhad-linux
gcc version 4.6.2
JAVA: jdk 1.7.0
GNU Make 3.82
(What else info do you need?)

Command: make ohNetAndroidNative

Thanks


RE: New to OhNet, need help - simonc - 04-03-2013 09:02 PM

(04-03-2013 06:43 PM)dcong Wrote:  I compiled it myself.

OS: i686-redhad-linux
gcc version 4.6.2
JAVA: jdk 1.7.0
GNU Make 3.82
(What else info do you need?)

Command: make ohNetAndroidNative

Random guess, you're not building 64-bit native code then running it against 32-bit Java code by any chance?


RE: New to OhNet, need help - dcong - 04-03-2013 09:12 PM

(04-03-2013 09:02 PM)simonc Wrote:  
(04-03-2013 06:43 PM)dcong Wrote:  I compiled it myself.

OS: i686-redhad-linux
gcc version 4.6.2
JAVA: jdk 1.7.0
GNU Make 3.82
(What else info do you need?)

Command: make ohNetAndroidNative

Random guess, you're not building 64-bit native code then running it against 32-bit Java code by any chance?

What is the command to build native code?

I did have libohNetJni.so and libohNet.so in /Build/obj/Posix/Release/Android/libs/armeabi


RE: New to OhNet, need help - simonc - 04-03-2013 10:21 PM

(04-03-2013 09:12 PM)dcong Wrote:  
(04-03-2013 09:02 PM)simonc Wrote:  Random guess, you're not building 64-bit native code then running it against 32-bit Java code by any chance?

What is the command to build native code?

I did have libohNetJni.so and libohNet.so in /Build/obj/Posix/Release/Android/libs/armeabi

Your build command - make ohNetAndroidNative - is correct. If you want to avoid gcc producing a build which targets the platform you're building on, you can set the CROSS_COMPILE environment variable before building. Depending on the cross compiler you choose, you may then get a 64 or 32-bit binary.