[android-developers] Re: Native Shared Lib

2009-10-27 Thread David Turner
you're using the wrong path.

If the library was generated with the NDK, it should be installed under
/data/data/*appname*/*lib*/libnative.so

Also, you could try directly

System.loadLibrary(native);

that will translate to the same thing automatically.

On Mon, Oct 26, 2009 at 9:49 AM, Sanjay sanjai...@gmail.com wrote:


 Hi,

 I'm trying to create a shared lib written in c++. I followed all the
 steps which are recommended to create the shared lib and to access the
 native code in Android. But so far I couldn't succeeded in loading the
 shared lib on device or emulator. When I tried to load the lib by:

 static{
   System.load(/data/data/com.android/libnative.so);
 }

 I am getting this error:

 10-26 11:16:57.269: DEBUG/dalvikvm(714): Trying to load lib /data/data/
 com.android/libnative.so 0x435942a8

 10-26 11:16:57.429: INFO/dalvikvm(714): Unable to dlopen(/data/data/
 com.android/libnative.so): Cannot find library

 10-26 11:16:57.489: DEBUG/AndroidRuntime(714): Shutting down VM

 10-26 11:16:57.489: WARN/dalvikvm(714): threadid=3: thread exiting
 with uncaught exception (group=0x4000fe70)

 10-26 11:16:57.519: ERROR/AndroidRuntime(714): Uncaught handler:
 thread main exiting due to uncaught exception

 10-26 11:16:57.671: ERROR/AndroidRuntime(714):
 java.lang.UnsatisfiedLinkError: Library /data/data/com.android/
 libnative.so not found

 10-26 11:16:57.671: ERROR/AndroidRuntime(714): at
 java.lang.Runtime.load(Runtime.java:437)
 10-26 11:16:57.671: ERROR/AndroidRuntime(714): at
 java.lang.System.load(System.java:536)

 .

 Could anybody please help me out to resolve the above issue.

 I also came across this post which says that if the code is written in
 c++, we always get issues with shared lib.


 http://markmail.org/message/vxakxs6g5yplkdjv#query:unable%20to%20dlopen%20cannot%20load%20library+page:1+mid:wqdw3yf2gqh3g6w5+state:results

 Could anyone assert the above statement?

 I'm trying hard to get over this issue but so far couldn't get any
 fruitful result.

 I highly appreciate for your time and help.

 Thank you,
 Sanjay

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Native Shared Lib

2009-10-26 Thread Roman ( T-Mobile USA)

Change the following code

static{
   System.load(/data/data/com.android/libnative.so);

}


to


static{
   System.load(native);

}

and make sure that your lib is in folder  data/data/your app folder/
lib (the lib is placed automatically in this folder).

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.


On Oct 26, 9:49 am, Sanjay sanjai...@gmail.com wrote:
 Hi,

 I'm trying to create a shared lib written in c++. I followed all the
 steps which are recommended to create the shared lib and to access the
 native code in Android. But so far I couldn't succeeded in loading the
 shared lib on device or emulator. When I tried to load the lib by:

 static{
        System.load(/data/data/com.android/libnative.so);

 }

 I am getting this error:

 10-26 11:16:57.269: DEBUG/dalvikvm(714): Trying to load lib /data/data/
 com.android/libnative.so 0x435942a8

 10-26 11:16:57.429: INFO/dalvikvm(714): Unable to dlopen(/data/data/
 com.android/libnative.so): Cannot find library

 10-26 11:16:57.489: DEBUG/AndroidRuntime(714): Shutting down VM

 10-26 11:16:57.489: WARN/dalvikvm(714): threadid=3: thread exiting
 with uncaught exception (group=0x4000fe70)

 10-26 11:16:57.519: ERROR/AndroidRuntime(714): Uncaught handler:
 thread main exiting due to uncaught exception

 10-26 11:16:57.671: ERROR/AndroidRuntime(714):
 java.lang.UnsatisfiedLinkError: Library /data/data/com.android/
 libnative.so not found

 10-26 11:16:57.671: ERROR/AndroidRuntime(714):     at
 java.lang.Runtime.load(Runtime.java:437)
 10-26 11:16:57.671: ERROR/AndroidRuntime(714):     at
 java.lang.System.load(System.java:536)

 .

 Could anybody please help me out to resolve the above issue.

 I also came across this post which says that if the code is written in
 c++, we always get issues with shared lib.

 http://markmail.org/message/vxakxs6g5yplkdjv#query:unable%20to%20dlop...

 Could anyone assert the above statement?

 I'm trying hard to get over this issue but so far couldn't get any
 fruitful result.

 I highly appreciate for your time and help.

 Thank you,
 Sanjay
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---