Re: [android-developers] Re: JNI on SDCard?

2013-05-16 Thread Filipe Madureira
Hi,

Thanks for the help.
The problem is that I don't know where the libraries go to when I move the
app to SD on my HTC for me to use System.load().

So the only workaround I found is to check for the existance of the .so
file in the predefined folder /data/data/your_package_name/lib.
If it is not there, then I unzip it from the package APK file to
/data/data/your_package_name/files folder and load it from there.

Thanks



On Wed, May 15, 2013 at 11:29 PM, Piren gpi...@gmail.com wrote:

 That's actually the same person making pretty much the same reply :-)


 On Thursday, May 16, 2013 1:02:10 AM UTC+3, bob wrote:

 I found this one using Google:

 https://groups.google.com/**forum/?fromgroups=#!topic/**
 android-ndk/0uY4qgam1Wshttps://groups.google.com/forum/?fromgroups=#!topic/android-ndk/0uY4qgam1Ws

 It says:

 You must use System.load() if you want to specify the full path name
 of the file, System.loadLibrary() is only for ones in the default
 location.

 Also *you should not be able to load an .so off the SDCARD on an ARM *
 *system by normal means*, as ARM supports non-executable pages and
 android's implementation of mmap() refuses to map executable pages
 backed by a noexec file system.  To load from such a file system you
 would have to map anonymous executable pages and manually load the .so
 into them, doing appropriate interpretation of the contents and all
 fixups normally performed by the runtime linker.

 Thanks.


 On Wednesday, May 15, 2013 4:32:37 PM UTC-5, Piren wrote:

 That's what bing got me :)

 http://stackoverflow.com/**questions/2826412/how-to-load-**
 jni-from-sd-card-on-android-2-**1http://stackoverflow.com/questions/2826412/how-to-load-jni-from-sd-card-on-android-2-1

 On Wednesday, May 15, 2013 12:00:50 PM UTC+3, Filipe wrote:

 Hi,

 I had only used Bing up till now ;)
 Thanks for your great tutorial on this new thing called Google.
 I tryed it, but still did not find the answer.

 The libs are under the /data/data/your_package_name/**lib folder.
 When I move the App I start getting java.lang.**UnsatisfiedLinkError:
 findLibrary returned null

 I found some new things
 This works without problems on AVD. But I noticed that even if I move
 the App to the sdcard on the AVD, the lib remains in the same folder.

 So maybe the problem is specific to my HTC.
 Using adb shell I can find the libs in this folder. After moving to
 sdcard, when I use adb shell I get permission denied trying to access
 the lib folder !!!
 So I'm gessing that on my HTC the libs are moved, I just don't know
 where to.


 Thanks

 Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that I
 load using System.loadLibrary(**myNativeLib).


 Those libraries are native to what platform?



 This works great, but if I move my app to the SDCard it stops
 working, because it can't load the library.


 Did you take note of this from the Javadocs for 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for
 loading the library is implementation-dependent.

 Where did you put the library on the device. Is this where the system
 expects to find libraries?

  Are there any limitations on moving the app to SDCard when using jni?
 Or do I have to change my call to System.loadLibrary ?


 http://developer.android.com/**reference/java/lang/System.**
 html#loadLibrary(java.lang.**String)http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+**JNI http://lmgtfy.com/?q=Android+JNI

 --
 Lew


  --
 --
 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
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/SmKVuQU0zN8/unsubscribe?hl=en
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and 

Re: [android-developers] Re: JNI on SDCard?

2013-05-16 Thread Nikolay Elenkov
On Thu, May 16, 2013 at 6:19 PM, Filipe Madureira
filipe.ma...@gmail.com wrote:
 Hi,

 Thanks for the help.
 The problem is that I don't know where the libraries go to when I move the
 app to SD on my HTC for me to use System.load().


IIRC, the encrypted packages stored on SD card are loopback mounted.
Try running 'mount' in a shell and look for you package name. That
should lead you to the directory where your code is. Not 100% sure
it includes the native libs though.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: JNI on SDCard?

2013-05-16 Thread Nikolay Elenkov
On Thu, May 16, 2013 at 6:29 PM, Nikolay Elenkov
nikolay.elen...@gmail.com wrote:
 On Thu, May 16, 2013 at 6:19 PM, Filipe Madureira
 filipe.ma...@gmail.com wrote:
 Hi,

 Thanks for the help.
 The problem is that I don't know where the libraries go to when I move the
 app to SD on my HTC for me to use System.load().


 IIRC, the encrypted packages stored on SD card are loopback mounted.
 Try running 'mount' in a shell and look for you package name. That
 should lead you to the directory where your code is. Not 100% sure
 it includes the native libs though.

It should be in /mnt/asec/org.yourpackage-1/lib/native.so

or a similar looking directory.

The system should have taken care of setting paths, etc.
though and you shouldn't need to do anything special. My apps
with native code work just fine when moved on the SD card.
You are probably hitting a bug in a particular device or
Android version.

Note the this not using the SD card directly, but a loopback
mounted device with appropriate UID and options set:

/dev/block/dm-11 on /mnt/asec/org.package-2 type vfat
(ro,dirsync,nosuid,nodev,relatime,uid=1000,fmask=0222,dmask=0222,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: JNI on SDCard?

2013-05-16 Thread Nikolay Elenkov
On Thu, May 16, 2013 at 9:16 PM, Nikolay Elenkov
nikolay.elen...@gmail.com wrote:
 On Thu, May 16, 2013 at 6:29 PM, Nikolay Elenkov
 nikolay.elen...@gmail.com wrote:
 On Thu, May 16, 2013 at 6:19 PM, Filipe Madureira
 filipe.ma...@gmail.com wrote:
 Hi,

 Thanks for the help.
 The problem is that I don't know where the libraries go to when I move the
 app to SD on my HTC for me to use System.load().


 IIRC, the encrypted packages stored on SD card are loopback mounted.
 Try running 'mount' in a shell and look for you package name. That
 should lead you to the directory where your code is. Not 100% sure
 it includes the native libs though.

 It should be in /mnt/asec/org.yourpackage-1/lib/native.so

 or a similar looking directory.


BTW, getApplicationInfo().nativeLibraryDir should give you this
programatically.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: JNI on SDCard?

2013-05-16 Thread bob
You may want to take a look here:

http://developer.android.com/guide/topics/data/install-location.html

In particular:

*  
   *

Beginning with API Level 8, you can allow your application to be installed 
on the external storage (for example, the device's SD card). This is an 
optional feature you can declare for your application with the 
android:installLocation manifest attribute. *If you do not declare this 
attribute, your application will be installed on the internal storage only 
and it cannot be moved to the external storage.*
*
*
*
*
*  
   *
*
*

It seems like the obvious solution is to just disallow people to move your 
app to the external storage.

Thanks.


On Thursday, May 16, 2013 4:19:20 AM UTC-5, Filipe wrote:

 Hi,
  
 Thanks for the help.
 The problem is that I don't know where the libraries go to when I move the 
 app to SD on my HTC for me to use System.load().
  
 So the only workaround I found is to check for the existance of the .so 
 file in the predefined folder /data/data/your_package_name/lib.
 If it is not there, then I unzip it from the package APK file to 
 /data/data/your_package_name/files folder and load it from there.
  
 Thanks
  


 On Wed, May 15, 2013 at 11:29 PM, Piren gpi...@gmail.com javascript:wrote:

 That's actually the same person making pretty much the same reply :-)
  

 On Thursday, May 16, 2013 1:02:10 AM UTC+3, bob wrote:

 I found this one using Google:

 https://groups.google.com/**forum/?fromgroups=#!topic/**
 android-ndk/0uY4qgam1Wshttps://groups.google.com/forum/?fromgroups=#!topic/android-ndk/0uY4qgam1Ws

 It says:

 You must use System.load() if you want to specify the full path name 
 of the file, System.loadLibrary() is only for ones in the default 
 location. 

 Also *you should not be able to load an .so off the SDCARD on an ARM *
 *system by normal means*, as ARM supports non-executable pages and 
 android's implementation of mmap() refuses to map executable pages 
 backed by a noexec file system.  To load from such a file system you 
 would have to map anonymous executable pages and manually load the .so 
 into them, doing appropriate interpretation of the contents and all 
 fixups normally performed by the runtime linker. 

 Thanks.


 On Wednesday, May 15, 2013 4:32:37 PM UTC-5, Piren wrote:

 That's what bing got me :)
  
 http://stackoverflow.com/**questions/2826412/how-to-load-**
 jni-from-sd-card-on-android-2-**1http://stackoverflow.com/questions/2826412/how-to-load-jni-from-sd-card-on-android-2-1

 On Wednesday, May 15, 2013 12:00:50 PM UTC+3, Filipe wrote:

 Hi,
  
 I had only used Bing up till now ;)
 Thanks for your great tutorial on this new thing called Google.
 I tryed it, but still did not find the answer.
  
 The libs are under the /data/data/your_package_name/**lib folder.
 When I move the App I start getting java.lang.**UnsatisfiedLinkError: 
 findLibrary returned null
  
 I found some new things
 This works without problems on AVD. But I noticed that even if I move 
 the App to the sdcard on the AVD, the lib remains in the same folder.
  
 So maybe the problem is specific to my HTC.
 Using adb shell I can find the libs in this folder. After moving to 
 sdcard, when I use adb shell I get permission denied trying to access 
 the lib folder !!!
 So I'm gessing that on my HTC the libs are moved, I just don't know 
 where to.
  
  
 Thanks

 Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that 
 I load using System.loadLibrary(**myNativeLib).


 Those libraries are native to what platform?
  

  
 This works great, but if I move my app to the SDCard it stops 
 working, because it can't load the library.


 Did you take note of this from the Javadocs for 
 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for 
 loading the library is implementation-dependent. 

 Where did you put the library on the device. Is this where the system 
 expects to find libraries?

  Are there any limitations on moving the app to SDCard when using 
 jni? Or do I have to change my call to System.loadLibrary ?


 http://developer.android.com/**reference/java/lang/System.**
 html#loadLibrary(java.lang.**String)http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+**JNI http://lmgtfy.com/?q=Android+JNI

 -- 
 Lew
  

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to 
 android-d...@googlegroups.comjavascript:
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com javascript:
 For more options, visit this group 

Re: [android-developers] Re: JNI on SDCard?

2013-05-16 Thread Filipe Madureira
Thanks for the help.

Using the hint on getApplicationInfo().nativeLibraryDir I could confirm
it is a problem on this specific HTC. Probably a bug.
On AVD and on a Samnsung it works correctly and I confirmed the existence
of the lib files in getApplicationInfo().nativeLibraryDir.
On the HTC they are not there when I move the app.

Thanks


On Thu, May 16, 2013 at 2:42 PM, bob b...@coolfone.comze.com wrote:

 You may want to take a look here:

 http://developer.android.com/guide/topics/data/install-location.html

 In particular:

 *
  *

 Beginning with API Level 8, you can allow your application to be installed
 on the external storage (for example, the device's SD card). This is an
 optional feature you can declare for your application with the
 android:installLocation manifest attribute. *If you do not declare this
 attribute, your application will be installed on the internal storage only
 and it cannot be moved to the external storage.*
 *
 *
 *
 *
 *
  *
 *
 *

 It seems like the obvious solution is to just disallow people to move your
 app to the external storage.

 Thanks.


 On Thursday, May 16, 2013 4:19:20 AM UTC-5, Filipe wrote:

 Hi,

 Thanks for the help.
 The problem is that I don't know where the libraries go to when I move
 the app to SD on my HTC for me to use System.load().

 So the only workaround I found is to check for the existance of the .so
 file in the predefined folder /data/data/your_package_name/**lib.
 If it is not there, then I unzip it from the package APK file to
 /data/data/your_package_name/**files folder and load it from there.

 Thanks



 On Wed, May 15, 2013 at 11:29 PM, Piren gpi...@gmail.com wrote:

 That's actually the same person making pretty much the same reply :-)


 On Thursday, May 16, 2013 1:02:10 AM UTC+3, bob wrote:

 I found this one using Google:

 https://groups.google.com/**foru**m/?fromgroups=#!topic/**android-**
 ndk/0uY4qgam1Wshttps://groups.google.com/forum/?fromgroups=#!topic/android-ndk/0uY4qgam1Ws

 It says:

 You must use System.load() if you want to specify the full path name
 of the file, System.loadLibrary() is only for ones in the default
 location.

 Also *you should not be able to load an .so off the SDCARD on an ARM *
 *system by normal means*, as ARM supports non-executable pages and
 android's implementation of mmap() refuses to map executable pages
 backed by a noexec file system.  To load from such a file system you
 would have to map anonymous executable pages and manually load the .so
 into them, doing appropriate interpretation of the contents and all
 fixups normally performed by the runtime linker.

 Thanks.


 On Wednesday, May 15, 2013 4:32:37 PM UTC-5, Piren wrote:

 That's what bing got me :)

 http://stackoverflow.com/**quest**ions/2826412/how-to-load-**jni-**
 from-sd-card-on-android-2-**1http://stackoverflow.com/questions/2826412/how-to-load-jni-from-sd-card-on-android-2-1

 On Wednesday, May 15, 2013 12:00:50 PM UTC+3, Filipe wrote:

 Hi,

 I had only used Bing up till now ;)
 Thanks for your great tutorial on this new thing called Google.
 I tryed it, but still did not find the answer.

 The libs are under the /data/data/your_package_name/lib folder.
 When I move the App I start getting java.lang.**UnsatisfiedLinkError*
 *: findLibrary returned null

 I found some new things
 This works without problems on AVD. But I noticed that even if I move
 the App to the sdcard on the AVD, the lib remains in the same folder.

 So maybe the problem is specific to my HTC.
 Using adb shell I can find the libs in this folder. After moving to
 sdcard, when I use adb shell I get permission denied trying to access
 the lib folder !!!
 So I'm gessing that on my HTC the libs are moved, I just don't know
 where to.


 Thanks

 Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that
 I load using System.loadLibrary(**myNativeLi**b).


 Those libraries are native to what platform?



 This works great, but if I move my app to the SDCard it stops
 working, because it can't load the library.


 Did you take note of this from the Javadocs for
 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for
 loading the library is implementation-dependent.

 Where did you put the library on the device. Is this where the
 system expects to find libraries?

  Are there any limitations on moving the app to SDCard when using
 jni? Or do I have to change my call to System.loadLibrary ?


 http://developer.android.com/**r**eference/java/lang/System.**html**
 #loadLibrary(java.lang.**String)http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+**J**NIhttp://lmgtfy.com/?q=Android+JNI

 --
 Lew


  --
 --
 You received this message because you are subscribed to the Google
 Groups Android 

[android-developers] Re: JNI on SDCard?

2013-05-15 Thread Filipe
Hi,
 
I had only used Bing up till now ;)
Thanks for your great tutorial on this new thing called Google.
I tryed it, but still did not find the answer.
 
The libs are under the /data/data/your_package_name/lib folder.
When I move the App I start getting java.lang.UnsatisfiedLinkError: 
findLibrary returned null
 
I found some new things
This works without problems on AVD. But I noticed that even if I move the 
App to the sdcard on the AVD, the lib remains in the same folder.
 
So maybe the problem is specific to my HTC.
Using adb shell I can find the libs in this folder. After moving to 
sdcard, when I use adb shell I get permission denied trying to access 
the lib folder !!!
So I'm gessing that on my HTC the libs are moved, I just don't know where 
to.
 
 
Thanks

Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that I 
 load using System.loadLibrary(myNativeLib).


 Those libraries are native to what platform?
  

  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.


 Did you take note of this from the Javadocs for 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for loading 
 the library is implementation-dependent. 

 Where did you put the library on the device. Is this where the system 
 expects to find libraries?

  Are there any limitations on moving the app to SDCard when using jni? Or 
 do I have to change my call to System.loadLibrary ?



 http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+JNI

 -- 
 Lew
  


-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI on SDCard?

2013-05-15 Thread Filipe

Terça-feira, 14 de Maio de 2013 17:41:56 UTC+1, Filipe escreveu:

 Hi
  
 I have a project in Eclipse that uses some jni libraries that I load using 
 System.loadLibrary(myNativeLib).
  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.
  
 Are there any limitations on moving the app to SDCard when using jni? Or 
 do I have to change my call to System.loadLibrary ?
  
 Thanks


-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI on SDCard?

2013-05-15 Thread Piren
That's what bing got me :)
 
http://stackoverflow.com/questions/2826412/how-to-load-jni-from-sd-card-on-android-2-1

On Wednesday, May 15, 2013 12:00:50 PM UTC+3, Filipe wrote:

 Hi,
  
 I had only used Bing up till now ;)
 Thanks for your great tutorial on this new thing called Google.
 I tryed it, but still did not find the answer.
  
 The libs are under the /data/data/your_package_name/lib folder.
 When I move the App I start getting java.lang.UnsatisfiedLinkError: 
 findLibrary returned null
  
 I found some new things
 This works without problems on AVD. But I noticed that even if I move the 
 App to the sdcard on the AVD, the lib remains in the same folder.
  
 So maybe the problem is specific to my HTC.
 Using adb shell I can find the libs in this folder. After moving to 
 sdcard, when I use adb shell I get permission denied trying to access 
 the lib folder !!!
 So I'm gessing that on my HTC the libs are moved, I just don't know where 
 to.
  
  
 Thanks

 Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that I 
 load using System.loadLibrary(myNativeLib).


 Those libraries are native to what platform?
  

  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.


 Did you take note of this from the Javadocs for 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for loading 
 the library is implementation-dependent. 

 Where did you put the library on the device. Is this where the system 
 expects to find libraries?

  Are there any limitations on moving the app to SDCard when using jni? Or 
 do I have to change my call to System.loadLibrary ?



 http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+JNI

 -- 
 Lew
  



-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI on SDCard?

2013-05-15 Thread bob
I found this one using Google:

https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/0uY4qgam1Ws

It says:

You must use System.load() if you want to specify the full path name 
of the file, System.loadLibrary() is only for ones in the default 
location. 

Also *you should not be able to load an .so off the SDCARD on an ARM *
*system by normal means*, as ARM supports non-executable pages and 
android's implementation of mmap() refuses to map executable pages 
backed by a noexec file system.  To load from such a file system you 
would have to map anonymous executable pages and manually load the .so 
into them, doing appropriate interpretation of the contents and all 
fixups normally performed by the runtime linker. 

Thanks.


On Wednesday, May 15, 2013 4:32:37 PM UTC-5, Piren wrote:

 That's what bing got me :)
  

 http://stackoverflow.com/questions/2826412/how-to-load-jni-from-sd-card-on-android-2-1

 On Wednesday, May 15, 2013 12:00:50 PM UTC+3, Filipe wrote:

 Hi,
  
 I had only used Bing up till now ;)
 Thanks for your great tutorial on this new thing called Google.
 I tryed it, but still did not find the answer.
  
 The libs are under the /data/data/your_package_name/lib folder.
 When I move the App I start getting java.lang.UnsatisfiedLinkError: 
 findLibrary returned null
  
 I found some new things
 This works without problems on AVD. But I noticed that even if I move the 
 App to the sdcard on the AVD, the lib remains in the same folder.
  
 So maybe the problem is specific to my HTC.
 Using adb shell I can find the libs in this folder. After moving to 
 sdcard, when I use adb shell I get permission denied trying to access 
 the lib folder !!!
 So I'm gessing that on my HTC the libs are moved, I just don't know where 
 to.
  
  
 Thanks

 Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that I 
 load using System.loadLibrary(myNativeLib).


 Those libraries are native to what platform?
  

  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.


 Did you take note of this from the Javadocs for 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for loading 
 the library is implementation-dependent. 

 Where did you put the library on the device. Is this where the system 
 expects to find libraries?

  Are there any limitations on moving the app to SDCard when using jni? 
 Or do I have to change my call to System.loadLibrary ?



 http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+JNI

 -- 
 Lew
  



-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI on SDCard?

2013-05-15 Thread Piren
That's actually the same person making pretty much the same reply :-)
 

On Thursday, May 16, 2013 1:02:10 AM UTC+3, bob wrote:

 I found this one using Google:

 https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/0uY4qgam1Ws

 It says:

 You must use System.load() if you want to specify the full path name 
 of the file, System.loadLibrary() is only for ones in the default 
 location. 

 Also *you should not be able to load an .so off the SDCARD on an ARM *
 *system by normal means*, as ARM supports non-executable pages and 
 android's implementation of mmap() refuses to map executable pages 
 backed by a noexec file system.  To load from such a file system you 
 would have to map anonymous executable pages and manually load the .so 
 into them, doing appropriate interpretation of the contents and all 
 fixups normally performed by the runtime linker. 

 Thanks.


 On Wednesday, May 15, 2013 4:32:37 PM UTC-5, Piren wrote:

 That's what bing got me :)
  

 http://stackoverflow.com/questions/2826412/how-to-load-jni-from-sd-card-on-android-2-1

 On Wednesday, May 15, 2013 12:00:50 PM UTC+3, Filipe wrote:

 Hi,
  
 I had only used Bing up till now ;)
 Thanks for your great tutorial on this new thing called Google.
 I tryed it, but still did not find the answer.
  
 The libs are under the /data/data/your_package_name/lib folder.
 When I move the App I start getting java.lang.UnsatisfiedLinkError: 
 findLibrary returned null
  
 I found some new things
 This works without problems on AVD. But I noticed that even if I move 
 the App to the sdcard on the AVD, the lib remains in the same folder.
  
 So maybe the problem is specific to my HTC.
 Using adb shell I can find the libs in this folder. After moving to 
 sdcard, when I use adb shell I get permission denied trying to access 
 the lib folder !!!
 So I'm gessing that on my HTC the libs are moved, I just don't know 
 where to.
  
  
 Thanks

 Terça-feira, 14 de Maio de 2013 23:51:21 UTC+1, Lew escreveu:

 Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that I 
 load using System.loadLibrary(myNativeLib).


 Those libraries are native to what platform?
  

  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.


 Did you take note of this from the Javadocs for 'System.loadLibrary()'?
 The mapping of the specified library name to the full path for 
 loading the library is implementation-dependent. 

 Where did you put the library on the device. Is this where the system 
 expects to find libraries?

  Are there any limitations on moving the app to SDCard when using jni? 
 Or do I have to change my call to System.loadLibrary ?



 http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

 Also, I see some potentially useful links here:
 http://lmgtfy.com/?q=Android+JNI

 -- 
 Lew
  



-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI on SDCard?

2013-05-14 Thread RichardC
No. What errors do you get in LogCat?


On Tuesday, May 14, 2013 5:41:56 PM UTC+1, Filipe wrote:

 Hi
  
 I have a project in Eclipse that uses some jni libraries that I load using 
 System.loadLibrary(myNativeLib).
  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.
  
 Are there any limitations on moving the app to SDCard when using jni? Or 
 do I have to change my call to System.loadLibrary ?
  
 Thanks


-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI on SDCard?

2013-05-14 Thread Lew
Filipe wrote:

 I have a project in Eclipse that uses some jni [sic] libraries that I load 
 using System.loadLibrary(myNativeLib).


Those libraries are native to what platform?
 

  
 This works great, but if I move my app to the SDCard it stops working, 
 because it can't load the library.


Did you take note of this from the Javadocs for 'System.loadLibrary()'?
The mapping of the specified library name to the full path for loading the 
library is implementation-dependent. 

Where did you put the library on the device. Is this where the system 
expects to find libraries?

 Are there any limitations on moving the app to SDCard when using jni? Or 
 do I have to change my call to System.loadLibrary ?


http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

Also, I see some potentially useful links here:
http://lmgtfy.com/?q=Android+JNI

-- 
Lew
 

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: JNI Error : local reference table overflow (max=512) in ICS android version

2012-06-18 Thread Subramanya Somayaji
http://code.google.com/p/android/issues/detail?id=20686 

-- 
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: JNI Error : local reference table overflow (max=512) in ICS android version

2012-06-12 Thread Subramanya Somayaji
I'm having same issues while loading many android webview dynamically in 
viewpager 
http://stackoverflow.com/questions/10942929/viewpager-webview-memory-issue/10943022#10943022
 

-- 
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: JNI and caching jobject thiz?

2012-01-17 Thread Doug
This issue will come up whether or not you are using Android.  JNI can
be used on any JVM that supports it and will have the same semantics
and requirements.  Android is in no way special to what you're asking.

You should try consulting a JNI specification or reading something
like this:

http://java.sun.com/docs/books/jni/html/jniTOC.html

Doug

On Jan 16, 1:34 am, M J fakeacc...@googlemail.com wrote:
 Hey,

 hmmm, I do not think so. I just want to know how to call a Java method
 from C without having the jobject. Can I cache it when I previously
 got it as parameter?

 On 16 Jan., 09:11, FrankG frankgru...@googlemail.com wrote:







  Hello !

  It seems for me, that your question is not really  ndk and android
  related,
  instead more or less something related to Reflection and the Dynamic
  Invocation API.

  Good luck ! Frank

  On 13 Jan., 11:11, M J fakeacc...@googlemail.com wrote:

   Hey guys,

   I nned your help. I am currently developing an application which uses
   JNI and native sockets. The problem is that I have to call Java code
   if some packages arrive on the native socket connection. Currently I
   am using CallVoidMethod to do that. The JNIEnv cannot be cached so I
   get it like this:

   inline JNIEnv *get_env()
   {
           JNIEnv *env;
           jvm-GetEnv((void **)env, JNI_VERSION_1_4);
           return env;

   }

   The jmethodID I is cached and initialized on startup. My only problem
   now is, how can I get the jobject? Currently I am making a global
   reference on the parameter jobject thiz, which is passed to my init
   function.

   Is this okay? I am asking because I am having some trouble with that,
   eg. the reference to the local and the global obj are exactly the
   same. And when I a call DeleteGlobalRef on the global reference there
   is a warning in the log cat output that this reference does not exist
   and the app crashes.

   I also tried using the local reference but then the CallVoidMethod
   crashes and the output says this reference does not exist, so I think
   I am on the right way.

   Thanks in advance!

-- 
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: JNI and caching jobject thiz?

2012-01-16 Thread FrankG
Hello !

It seems for me, that your question is not really  ndk and android
related,
instead more or less something related to Reflection and the Dynamic
Invocation API.

Good luck ! Frank




On 13 Jan., 11:11, M J fakeacc...@googlemail.com wrote:
 Hey guys,

 I nned your help. I am currently developing an application which uses
 JNI and native sockets. The problem is that I have to call Java code
 if some packages arrive on the native socket connection. Currently I
 am using CallVoidMethod to do that. The JNIEnv cannot be cached so I
 get it like this:

 inline JNIEnv *get_env()
 {
         JNIEnv *env;
         jvm-GetEnv((void **)env, JNI_VERSION_1_4);
         return env;

 }

 The jmethodID I is cached and initialized on startup. My only problem
 now is, how can I get the jobject? Currently I am making a global
 reference on the parameter jobject thiz, which is passed to my init
 function.

 Is this okay? I am asking because I am having some trouble with that,
 eg. the reference to the local and the global obj are exactly the
 same. And when I a call DeleteGlobalRef on the global reference there
 is a warning in the log cat output that this reference does not exist
 and the app crashes.

 I also tried using the local reference but then the CallVoidMethod
 crashes and the output says this reference does not exist, so I think
 I am on the right way.

 Thanks in advance!

-- 
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: JNI and caching jobject thiz?

2012-01-16 Thread M J
Hey,

hmmm, I do not think so. I just want to know how to call a Java method
from C without having the jobject. Can I cache it when I previously
got it as parameter?

On 16 Jan., 09:11, FrankG frankgru...@googlemail.com wrote:
 Hello !

 It seems for me, that your question is not really  ndk and android
 related,
 instead more or less something related to Reflection and the Dynamic
 Invocation API.

 Good luck ! Frank

 On 13 Jan., 11:11, M J fakeacc...@googlemail.com wrote:







  Hey guys,

  I nned your help. I am currently developing an application which uses
  JNI and native sockets. The problem is that I have to call Java code
  if some packages arrive on the native socket connection. Currently I
  am using CallVoidMethod to do that. The JNIEnv cannot be cached so I
  get it like this:

  inline JNIEnv *get_env()
  {
          JNIEnv *env;
          jvm-GetEnv((void **)env, JNI_VERSION_1_4);
          return env;

  }

  The jmethodID I is cached and initialized on startup. My only problem
  now is, how can I get the jobject? Currently I am making a global
  reference on the parameter jobject thiz, which is passed to my init
  function.

  Is this okay? I am asking because I am having some trouble with that,
  eg. the reference to the local and the global obj are exactly the
  same. And when I a call DeleteGlobalRef on the global reference there
  is a warning in the log cat output that this reference does not exist
  and the app crashes.

  I also tried using the local reference but then the CallVoidMethod
  crashes and the output says this reference does not exist, so I think
  I am on the right way.

  Thanks in advance!

-- 
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: JNI - FindClass() returns null

2011-10-12 Thread Bob
Sorry to revisit such an old post, but the answer by fadden is
precisely what I needed to know, and one that took some effort to dig
up.  The issue about non-system classes not being loaded will come up
if you are implementing callbacks from C into the JVM; there seem to
be plenty of other developers running in to this problem.

The reply by Andrew Stadler, JNI development is not currently
supported on the SDK, although true, might be a little misleading.
The point is that discussions about JNI belong in the NDK forum.

-- 
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: Jni To Java BLock THe UI thread.

2011-08-19 Thread Chris Stratton
On Monday, August 9, 2010 10:53:37 AM UTC-4, AlreadyAMember wrote:

 During this loop in C  in case of an error  I would like to 
 callback the java UI thread and pop up a dialog from C , the KEY is 
 C has to block and wait. 
 So if I create a thread and set up a handler in Java to show the 
 DIalog the the native C code won't block. I have also looked in to 
 Loopers Thinking that it could be helpful to block the C code. 

 Now of course I could be naive and write a while(wait) in c and as 
 soon as dialog is closed I can make a native call from java and set 
 the wait to false. 
 But that is just not cool. 


Actually that is approximately the right idea, only it would be better if 
the waiting thread could simply ask the kernel scheduler not to run it until 
the wait condition is satisfied, by calling a kernel function that will 
block until that is the case.  A semaphore is a classic operating system 
feature for accomplishing that.  A method for accomplishing nearly as much 
without requiring as much understanding of operating system services would 
be to just put a substantial sleep in the loop.

-- 
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

Re: [android-developers] Re: Jni To Java BLock THe UI thread.

2011-08-19 Thread Sudheer Bhat
If you can do with Java solution, then on Java side after calling
handler.sendMessage() call wait()  once the dialog is dismissed call
notify() (of course making sure to wait()  notify() on the same object).
Alternatively you could use CyclicBarrier or CountDownLatch in the
java.util.concurrent package. Hope that helps.

Regards,
Sudheer


On Fri, Aug 19, 2011 at 5:40 PM, Chris Stratton cs07...@gmail.com wrote:

 On Monday, August 9, 2010 10:53:37 AM UTC-4, AlreadyAMember wrote:

 During this loop in C  in case of an error  I would like to
 callback the java UI thread and pop up a dialog from C , the KEY is
 C has to block and wait.
 So if I create a thread and set up a handler in Java to show the
 DIalog the the native C code won't block. I have also looked in to
 Loopers Thinking that it could be helpful to block the C code.

 Now of course I could be naive and write a while(wait) in c and as
 soon as dialog is closed I can make a native call from java and set
 the wait to false.
 But that is just not cool.


 Actually that is approximately the right idea, only it would be better if
 the waiting thread could simply ask the kernel scheduler not to run it until
 the wait condition is satisfied, by calling a kernel function that will
 block until that is the case.  A semaphore is a classic operating system
 feature for accomplishing that.  A method for accomplishing nearly as much
 without requiring as much understanding of operating system services would
 be to just put a substantial sleep in the loop.

  --
 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


-- 
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

Re: [android-developers] Re: Jni To Java BLock THe UI thread.

2011-08-19 Thread Chris Stratton
On Friday, August 19, 2011 12:27:04 PM UTC-4, Sudheer wrote:

 If you can do with Java solution, then on Java side after calling 
 handler.sendMessage() call wait()  once the dialog is dismissed call 
 notify() (of course making sure to wait()  notify() on the same object). 
 Alternatively you could use CyclicBarrier or CountDownLatch in the 
 java.util.concurrent package. Hope that helps.


Yes, and there are similar mechanism in the native pthread library (which 
the above java capabilities may well be built upon)

 

-- 
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: JNI working

2011-01-12 Thread Richard Sámela
hmm I don't know but am I right if I think that the code written in C+
+ will be the same for both of processores. And OS will be the same
too. And as I know the android app is compilated by virtual machine
which is running under the android. So I don'tunderstand why deppends
on type of processor. But it could be true, I'm only asking.
thanks for answers

On 12. Jan, 01:28 h., John Gaby jg...@gabysoft.com wrote:
 I believe that there are devices (e.g. some tablets) out there that
 use MIPS processors rather than ARM.  Correct me if I am wrong, but I
 do not believe that code compiled for an ARM device will work on a
 MIPS device.

 On Jan 11, 11:35 am, Kumar Bibek coomar@gmail.com wrote:







  Yes, It will work on all devices...

  Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

  On Wed, Jan 12, 2011 at 1:03 AM, Richard Sámela feromak...@gmail.comwrote:

   Hi,
   I would like to know something about JNI. How it works in android?
   does it work on all devices? does it work on tablest with android?
   I want to use toolkit in C++ programing language.

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

-- 
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


Re: [android-developers] Re: JNI working

2011-01-12 Thread Kostya Vasilyev

Native code is... well native.

An .so packaged within an application contains machine code and runs 
directly on the processor (unlike .dex code).


-- Kostya

12.01.2011 13:36, Richard Sámela пишет:

hmm I don't know but am I right if I think that the code written in C+
+ will be the same for both of processores. And OS will be the same
too. And as I know the android app is compilated by virtual machine
which is running under the android. So I don'tunderstand why deppends
on type of processor. But it could be true, I'm only asking.
thanks for answers

On 12. Jan, 01:28 h., John Gabyjg...@gabysoft.com  wrote:

I believe that there are devices (e.g. some tablets) out there that
use MIPS processors rather than ARM.  Correct me if I am wrong, but I
do not believe that code compiled for an ARM device will work on a
MIPS device.

On Jan 11, 11:35 am, Kumar Bibekcoomar@gmail.com  wrote:








Yes, It will work on all devices...
Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
On Wed, Jan 12, 2011 at 1:03 AM, Richard Sámelaferomak...@gmail.comwrote:

Hi,
I would like to know something about JNI. How it works in android?
does it work on all devices? does it work on tablest with android?
I want to use toolkit in C++ programing language.
--
You received this message because you are subscribed to the Google
Groups Android Developers group.To post to this group, send email 
toandroid-develop...@googlegroups.com
To unsubscribe from this group, send email to  
android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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: JNI working

2011-01-11 Thread John Gaby
I believe that there are devices (e.g. some tablets) out there that
use MIPS processors rather than ARM.  Correct me if I am wrong, but I
do not believe that code compiled for an ARM device will work on a
MIPS device.

On Jan 11, 11:35 am, Kumar Bibek coomar@gmail.com wrote:
 Yes, It will work on all devices...

 Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

 On Wed, Jan 12, 2011 at 1:03 AM, Richard Sámela feromak...@gmail.comwrote:

  Hi,
  I would like to know something about JNI. How it works in android?
  does it work on all devices? does it work on tablest with android?
  I want to use toolkit in C++ programing language.

  --
  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.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
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: JNI CallVoidMethod can t call

2010-12-24 Thread TobyKaos
Then I manage to do what I want by using obj in CallVoidMethod. I am
sure to tried it before but debug is hard with JNI.

-- 
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: JNI Global Variables And activity change? / SIGKILL vs SIGTERM

2010-11-08 Thread fadden
On Nov 7, 9:47 am, lomoflicker evrenbin...@gmail.com wrote:
 1)
 Do cached global environments get deleted or somehow get corrupted
 when activities change ?

Not by the VM.

 2) SIGKILL vs SIGTERM.
 I know the differences of both. Can android native threads handle
 these signals ?

Nothing can handle SIGKILL.  SIGTERM should have its usual effect.

-- 
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: jni

2010-07-22 Thread FrankG
If it is a platform extension and part of the system,
that putting the shared lib in the apk will not help.
In this the lib must be unter /system/lib.

Good luck !

  Frank


On 22 Jul., 07:13, Rajesh Pelluru mail2pell...@gmail.com wrote:
 Hi,

 If your app uses native code then you need to include .so file in your apk
 file.
 Please check samples and docs of android ndk for more information.

 --Rajesh



 On Wed, Jul 21, 2010 at 12:53 PM, Vaishnavi vaishn...@gmail.com wrote:
  Hi,
  I have a problen in running jni code on android device(intel atom
  board).and the apk to \data\app.Is it enough to just place the .apk to
  run the code or should i also include the .so file. If needed where
  should i include the .so file

  --
  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.comandroid-developers%2bunsubs­cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en- Zitierten Text 
 ausblenden -

 - Zitierten Text anzeigen -

-- 
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: jni

2010-07-22 Thread Vaishnavi
Hi,
I am able 2 run the code in the emulator but when i try 2 put it on a
device i am getting an error which says: cannot find .so file.
I have included the.so file in /data/data/package/lib. but still i am
not able 2solve the error

On Jul 22, 10:13 am, Rajesh Pelluru mail2pell...@gmail.com wrote:
 Hi,

 If your app uses native code then you need to include .so file in your apk
 file.
 Please check samples and docs of android ndk for more information.

 --Rajesh



 On Wed, Jul 21, 2010 at 12:53 PM, Vaishnavi vaishn...@gmail.com wrote:
  Hi,
  I have a problen in running jni code on android device(intel atom
  board).and the apk to \data\app.Is it enough to just place the .apk to
  run the code or should i also include the .so file. If needed where
  should i include the .so file

  --
  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.comandroid-developers%2Bunsubs 
  cr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
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: jni

2010-07-22 Thread Vaishnavi
Hi,
I am able 2 run the code in the emulator but when i try 2 put it on a
device i am getting an error which says: cannot find .so file.
I have included the.so file in /data/data/package/lib. but still i am
not able 2solve the error


On Jul 22, 1:19 pm, FrankG frankgru...@googlemail.com wrote:
 If it is a platform extension and part of the system,
 that putting the shared lib in the apk will not help.
 In this the lib must be unter /system/lib.

 Good luck !

   Frank

 On 22 Jul., 07:13, Rajesh Pelluru mail2pell...@gmail.com wrote:



  Hi,

  If your app uses native code then you need to include .so file in your apk
  file.
  Please check samples and docs of android ndk for more information.

  --Rajesh

  On Wed, Jul 21, 2010 at 12:53 PM, Vaishnavi vaishn...@gmail.com wrote:
   Hi,
   I have a problen in runningjnicode on android device(intel atom
   board).and the apk to \data\app.Is it enough to just place the .apk to
   run the code or should i also include the .so file. If needed where
   should i include the .so file

   --
   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.comandroid-developers%2Bunsubs
­cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en-Zitierten Text 
  ausblenden -

  - Zitierten Text anzeigen -

-- 
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: JNI stdout, stdin

2010-04-27 Thread fadden
On Apr 26, 6:17 am, Budugu 369 budugu...@gmail.com wrote:
 Is it possible to redirect the stdout of JNI code to Java code and
 vice versa with stdin

I'm not entirely sure what you're asking, but the answer is probably
no.

There's a semi-documented sort-of-supported system property that will
redirect native stdout/stderr to the log file.  See
http://developer.android.com/guide/developing/tools/adb.html#stdout .

-- 
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: JNI Call Bridge

2009-12-10 Thread bacchus
Hi fadden,

Thank you very much for your answer. It cleared my thoughts on this
subject.

P.S. Sorry for the late reply but it took me some time to analyze your
answer.

Cheers,

On Dec 2, 9:47 pm, fadden fad...@android.com wrote:
 On Dec 2, 4:06 am, bacchus aeternal.de...@gmail.com wrote:

  By startup, I mean to understand how the Android Runtime is setup and
  Dalvik is started.

  Throughout the code reading process I've found VMRuntime.

 VMRuntime doesn't have a whole lot to do with that.  It just has some
 utility functions.  The class is defined here:

   dalvik/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java

 The native methods it refers to are defined here:

   dalvik/vm/native/dalvik_system_VMRuntime.c

 The VM is created by frameworks/base/core/jni/AndroidRuntime.cpp:

     if (JNI_CreateJavaVM(pJavaVM, pEnv, initArgs)  0) {

 The runtime initialization does a bunch of jumping around, some of
 which is cruft from the days before the zygote stuff existed.
 Here's a part of an explanation I wrote about a week ago when
 discussing something related:

 -
 AndroidRuntime.cpp starts the VM, calls into RuntimeInit.main().
 Crazy things happen.  We end up in ZygoteInit.main(), which has been
 requested to call Zygote.forkSystemServer() to create system_server.
 The zygote goes to sleep on a socket.

 (All of the magic forking and such happens in dalvik/vm/native/
 dalvik_system_Zygote.c .)

 At this point we have two processes: zygote (a VM with a single thread
 that is listening on a socket) and system_server (which was forked
 from zygote and is now busily doing stuff).  When system_server
 decides it wants to create a new app process, it sends an IPC to the
 zygote process, which calls Zygote.forkAndSpecialize().

 The forkAndSpecialize call takes a bunch of arguments, mostly having
 to do with what uid and capabilities the new process should have.
 (zygote runs as root.)  When the child process returns to Java-land,
 it reads some more stuff from the command socket, then closes it.
 -

-- 
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: JNI Call Bridge

2009-12-02 Thread bacchus
Hi Suchand,

Somehow the table you wanted to present got deformated.
Could you please provide me a web reference to it?

Thanks in advance.

Cheers

On Dec 1, 5:15 am, Suchand Ghosh chand4andr...@gmail.com wrote:
 I think you r looking for:

 Mapping types

 The following table shows the mapping of types between Java and native code.
   Native Type Java Language Type Description Type signature unsigned char
 jboolean unsigned 8 bits Z signed char jbyte signed 8 bits B unsigned short
 jchar unsigned 16 bits C short jshort signed 16 bits S long jint signed 32
 bits I

 long long
 __int64
 jlong signed 64 bits J float jfloat 32 bits F double jdouble 64 bits D

 In addition, the signature L fully-qualified-class ; would mean the class
 uniquely specified by that name; e.g., the signature Ljava/lang/String;
 refers to the class java.lang.String. Also, prefixing [ to the signature
 makes the array of that type; for example, [I means the int array type.

 Here, these types are interchangeable. You can use jint where you normally
 use an int, and vice-versa, without any
 typecastinghttp://en.wikipedia.org/wiki/Typecastrequired.

 However, mapping between Java Strings and arrays to native strings and
 arrays is different. If you use a jstring in where a char * would be, your
 code could crash the JVM.
 Cheers...

 BR,
 Chand

 On Tue, Dec 1, 2009 at 2:14 AM, fadden fad...@android.com wrote:
  On Nov 30, 9:08 am, bacchus aeternal.de...@gmail.com wrote:
   I'm looking for specific information about Android JNI Call Bridge.
   The one that exists does not suffices my needs.

  The JNI call bridge is a bit of code that converts an array of 32-
  bit values into C-style arguments.  It takes into account host-
  specific calling conventions, notably which arguments go into which
  registers (by type or position), which go onto the stack, and how
  values should be padded.

  The sources include a version based on libffi (slow) and a few CPU-
  specific implementations (ARM EABI, SH4, x86).

   I would like to understand the mappings performed between C/C++ data
   types and Java data types.

   As an example, I would like to understand where and how the VMRuntime
   object is defined and mapped.

  This is beyond the scope of the JNI function call interface.  If you
  want higher-level object to interact more directly, you may need to
  look into Cygnus CNI (requires compiler support) or JNA (convenience,
  but at a price).

  Was there something specific about VMRuntime that interested you?

  --
  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.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en



-- 
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: JNI Call Bridge

2009-12-02 Thread bacchus
Hi fadden,

Sorry for not being clearer on my first post.

I'm trying to understand better (through code reading) the startup
process of Android.
By startup, I mean to understand how the Android Runtime is setup and
Dalvik is started.

Throughout the code reading process I've found VMRuntime.

E.g. Call Stack
...
AndroidRuntime::start(...)
...
env-CallStaticVoidMethod(startClass, startMeth, strArray);

This method invokes com.android.internal.os.ZygoteInit.
Then, on ZygoteInit.java main() method there is the preloadClasses()
method.
This is where VMRuntime appears.

final VMRuntime runtime = VMRuntime.getRuntime();

Then, I've tried to figure out what properties does this object holds,
and I've found a singleton that, in the java side, represents an empty
object
which reference is returned through the getRuntime() method.

Well, as I was trying to understand in detail what this VMRuntime
object represents, initially I thought that it could be related to JNI
Call Bridge, but according to your answer it is not.

Therefore, I'm assuming that there must be a library or C/C++ code
that is invoked when getRuntime() or other VMRuntime class method is
called.

And this is still my question.
How/Where is this object mapped to native code?

Sorry for the long reply.
If I was not clear enough please tell me and then, I will try to
figure out a simple way to explain my problem.

Cheers,


On Nov 30, 8:44 pm, fadden fad...@android.com wrote:
 On Nov 30, 9:08 am, bacchus aeternal.de...@gmail.com wrote:

  I'm looking for specific information about Android JNI Call Bridge.
  The one that exists does not suffices my needs.

 The JNI call bridge is a bit of code that converts an array of 32-
 bit values into C-style arguments.  It takes into account host-
 specific calling conventions, notably which arguments go into which
 registers (by type or position), which go onto the stack, and how
 values should be padded.

 The sources include a version based on libffi (slow) and a few CPU-
 specific implementations (ARM EABI, SH4, x86).

  I would like to understand the mappings performed between C/C++ data
  types and Java data types.

  As an example, I would like to understand where and how the VMRuntime
  object is defined and mapped.

 This is beyond the scope of the JNI function call interface.  If you
 want higher-level object to interact more directly, you may need to
 look into Cygnus CNI (requires compiler support) or JNA (convenience,
 but at a price).

 Was there something specific about VMRuntime that interested you?

-- 
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: JNI Call Bridge

2009-12-02 Thread fadden
On Dec 2, 4:06 am, bacchus aeternal.de...@gmail.com wrote:
 By startup, I mean to understand how the Android Runtime is setup and
 Dalvik is started.

 Throughout the code reading process I've found VMRuntime.

VMRuntime doesn't have a whole lot to do with that.  It just has some
utility functions.  The class is defined here:

  dalvik/libcore/dalvik/src/main/java/dalvik/system/VMRuntime.java

The native methods it refers to are defined here:

  dalvik/vm/native/dalvik_system_VMRuntime.c


The VM is created by frameworks/base/core/jni/AndroidRuntime.cpp:

if (JNI_CreateJavaVM(pJavaVM, pEnv, initArgs)  0) {

The runtime initialization does a bunch of jumping around, some of
which is cruft from the days before the zygote stuff existed.
Here's a part of an explanation I wrote about a week ago when
discussing something related:

-
AndroidRuntime.cpp starts the VM, calls into RuntimeInit.main().
Crazy things happen.  We end up in ZygoteInit.main(), which has been
requested to call Zygote.forkSystemServer() to create system_server.
The zygote goes to sleep on a socket.

(All of the magic forking and such happens in dalvik/vm/native/
dalvik_system_Zygote.c .)

At this point we have two processes: zygote (a VM with a single thread
that is listening on a socket) and system_server (which was forked
from zygote and is now busily doing stuff).  When system_server
decides it wants to create a new app process, it sends an IPC to the
zygote process, which calls Zygote.forkAndSpecialize().

The forkAndSpecialize call takes a bunch of arguments, mostly having
to do with what uid and capabilities the new process should have.
(zygote runs as root.)  When the child process returns to Java-land,
it reads some more stuff from the command socket, then closes it.
-

-- 
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: JNI Call Bridge

2009-12-01 Thread fadden
On Nov 30, 9:15 pm, Suchand Ghosh chand4andr...@gmail.com wrote:
 Here, these types are interchangeable. You can use jint where you normally
 use an int, and vice-versa, without any
 typecastinghttp://en.wikipedia.org/wiki/Typecastrequired.

...sometimes.  On current Android systems, int and long are both
32-bit, so you're okay with jint==int, but if you assume jlong==long
you will be disappointed.  For portability you may not want to assume
jint==int.

The JNI types are defined to have specific bit widths, while most C
types aren't, so take care with your assumptions.  Make sure you
always use the JNI types in function prototypes, so at least the
arguments are passed in and returned correctly.

-- 
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: JNI Call Bridge

2009-11-30 Thread fadden
On Nov 30, 9:08 am, bacchus aeternal.de...@gmail.com wrote:
 I'm looking for specific information about Android JNI Call Bridge.
 The one that exists does not suffices my needs.

The JNI call bridge is a bit of code that converts an array of 32-
bit values into C-style arguments.  It takes into account host-
specific calling conventions, notably which arguments go into which
registers (by type or position), which go onto the stack, and how
values should be padded.

The sources include a version based on libffi (slow) and a few CPU-
specific implementations (ARM EABI, SH4, x86).

 I would like to understand the mappings performed between C/C++ data
 types and Java data types.

 As an example, I would like to understand where and how the VMRuntime
 object is defined and mapped.

This is beyond the scope of the JNI function call interface.  If you
want higher-level object to interact more directly, you may need to
look into Cygnus CNI (requires compiler support) or JNA (convenience,
but at a price).

Was there something specific about VMRuntime that interested you?

-- 
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


Re: [android-developers] Re: JNI Call Bridge

2009-11-30 Thread Suchand Ghosh
I think you r looking for:

Mapping types

The following table shows the mapping of types between Java and native code.
  Native Type Java Language Type Description Type signature unsigned char
jboolean unsigned 8 bits Z signed char jbyte signed 8 bits B unsigned short
jchar unsigned 16 bits C short jshort signed 16 bits S long jint signed 32
bits I

long long
__int64
jlong signed 64 bits J float jfloat 32 bits F double jdouble 64 bits D


In addition, the signature L fully-qualified-class ; would mean the class
uniquely specified by that name; e.g., the signature Ljava/lang/String;
refers to the class java.lang.String. Also, prefixing [ to the signature
makes the array of that type; for example, [I means the int array type.

Here, these types are interchangeable. You can use jint where you normally
use an int, and vice-versa, without any
typecastinghttp://en.wikipedia.org/wiki/Typecastrequired.

However, mapping between Java Strings and arrays to native strings and
arrays is different. If you use a jstring in where a char * would be, your
code could crash the JVM.
Cheers...

BR,
Chand

On Tue, Dec 1, 2009 at 2:14 AM, fadden fad...@android.com wrote:

 On Nov 30, 9:08 am, bacchus aeternal.de...@gmail.com wrote:
  I'm looking for specific information about Android JNI Call Bridge.
  The one that exists does not suffices my needs.

 The JNI call bridge is a bit of code that converts an array of 32-
 bit values into C-style arguments.  It takes into account host-
 specific calling conventions, notably which arguments go into which
 registers (by type or position), which go onto the stack, and how
 values should be padded.

 The sources include a version based on libffi (slow) and a few CPU-
 specific implementations (ARM EABI, SH4, x86).

  I would like to understand the mappings performed between C/C++ data
  types and Java data types.
 
  As an example, I would like to understand where and how the VMRuntime
  object is defined and mapped.

 This is beyond the scope of the JNI function call interface.  If you
 want higher-level object to interact more directly, you may need to
 look into Cygnus CNI (requires compiler support) or JNA (convenience,
 but at a price).

 Was there something specific about VMRuntime that interested you?

 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
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: JNI problem : from c Languege call Java method

2009-10-15 Thread Michael MacDonald

The method you are calling is not static, but you are not calling it
with an instance object.  You are calling it with the class object
instead.  Probably you want to make the method you are calling static.

zhangho wrote:
 JNI problem   : from c Languege call Java

 i think from c Languege call Java,
 but that CallIntMethod() return value is not equals getIpv6() - 99,
 CallIntMethod() its always return strange value is [-1091242504] or
 [11212] .

 additional i already slove [Method not found: 'getIpv6' '(I;)I']
 error.

 please help me!


 java Language:
   public void onCreate() {
   setConnecCallback2();
   }

   public static native void  setConnecCallback2();

   public int getIpv6(int ipv6){

   Log.i(JNI, Callback from Native Messenger to Java Hello Chat);

   return 99;
   }

   static {
   System.loadLibrary(mm);
   }


 cLanguage:
 #include string.h
 #include jni.h
 #include stdio.h
 #include pthread.h


 JNIEXPORT void JNICALL Java_com_ServersService_setConnecCallback2
 (JNIEnv *env, jobject this) {

   FILE *fd;
 fd = fopen(/sdcard/made.log, w);

   jclass jcCallback = (*env)-FindClass(env,com.ServersService);

   jmethodID mid = (*env)-GetMethodID(env,jcCallback,getIpv6,(I)I);

   int ii =  (int)(*env)-CallIntMethod(env, jcCallback  ,mid, 444 );


   fprintf(fd, iii is : [%d] \n,  ii);
   fclose(fd);

   return;
 }





--~--~-~--~~~---~--~~
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: JNI problem : from c Languege call Java method

2009-10-15 Thread zhangho

very thanks.

i'm already slove this problem  atGetStaticMethodID()
CallStaticIntMethod()  method.

On 10月16日, 午前7:54, Michael MacDonald googlec...@antlersoft.com
wrote:
 The method you are calling is not static, but you are not calling it
 with an instance object.  You are calling it with the class object
 instead.  Probably you want to make the method you are calling static.

 zhangho wrote:
  JNI problem   : from c Languege call Java

  i think from c Languege call Java,
  but that CallIntMethod() return value is not equals getIpv6() - 99,
  CallIntMethod() its always return strange value is [-1091242504] or
  [11212] .

  additional i already slove [Method not found: 'getIpv6' '(I;)I']
  error.

  please help me!

  java Language:
     public void onCreate() {
             setConnecCallback2();
     }

     public static native void  setConnecCallback2();

     public int getIpv6(int ipv6){

     Log.i(JNI, Callback from Native Messenger to Java Hello Chat);

             return 99;
     }

     static {
             System.loadLibrary(mm);
     }

  cLanguage:
  #include string.h
  #include jni.h
  #include stdio.h
  #include pthread.h

  JNIEXPORT void JNICALL Java_com_ServersService_setConnecCallback2
  (JNIEnv *env, jobject this) {

     FILE *fd;
  fd = fopen(/sdcard/made.log, w);

     jclass jcCallback = (*env)-FindClass(env,com.ServersService);

     jmethodID mid = (*env)-GetMethodID(env,jcCallback,getIpv6,(I)I);

     int ii =  (int)(*env)-CallIntMethod(env, jcCallback  ,mid, 444 );

     fprintf(fd, iii is : [%d] \n,  ii);
     fclose(fd);

     return;
  }


--~--~-~--~~~---~--~~
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: JNI callback problem

2009-09-15 Thread fadden

(1) This discussion should be on android-ndk.
(2) Make sure you have CheckJNI enabled (setprop dalvik.vm.checkjni
true) if you're not on the emulator.
(3) The logcat output will have some information about the crash that
you should include.


On Sep 15, 3:33 am, caval cavalzh...@gmail.com wrote:
 firstly I save JVM pointer in a native function which called when ap
 lauched:
 JNIEXPORT void JNICALL Java_com_caval_ServerList_Init
   (JNIEnv * env, jobject obj)
 {
 ...

 *// save jvm pointer*
 * **int nRt = env-GetJavaVM(jvm);*

 if (nRt == 0)
 fprintf(stdout, InitDLNACP -- GetJavaVM Success...\n);
 else
 fprintf(stderr, InitDLNACP -- GetJavaVM Failed...\n);

 }

 then, when some event echoed I will make a callback of some class in jvm

 void _callback()
 {
 JNIEnv *env = NULL;
 int nResult = -1;

 *nResult = jvm-AttachCurrentThread((void **)env, NULL);*
 *if ((nResult != 0) || (env == NULL))*
 {
 fprintf(stderr, -- In _Java_com_caval_now_Map_AddItem Thread Attached
 Failed.\n);
 return;

 }

 jstring ret = env-NewStringUTF(pszTitle); // I run to this line and ap
 crashed.
 jclass cls = env-FindClass(com/caval/now/ServerList);

 }

 the AttachCurrentThread func return OK and also I get the env pointer.
 but any call on env will crash.

 I have no idea of this issue...any help will highly appriciated.

 Regards,
 Caval.
--~--~-~--~~~---~--~~
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: JNI callback problem

2009-09-15 Thread caval
Thanks for your tip, but the options does not work.may be I should check
android JNI spec firstly.

2009/9/16 fadden fad...@android.com


 (1) This discussion should be on android-ndk.
 (2) Make sure you have CheckJNI enabled (setprop dalvik.vm.checkjni
 true) if you're not on the emulator.
 (3) The logcat output will have some information about the crash that
 you should include.


 On Sep 15, 3:33 am, caval cavalzh...@gmail.com wrote:
  firstly I save JVM pointer in a native function which called when ap
  lauched:
  JNIEXPORT void JNICALL Java_com_caval_ServerList_Init
(JNIEnv * env, jobject obj)
  {
  ...
 
  *// save jvm pointer*
  * **int nRt = env-GetJavaVM(jvm);*
 
  if (nRt == 0)
  fprintf(stdout, InitDLNACP -- GetJavaVM Success...\n);
  else
  fprintf(stderr, InitDLNACP -- GetJavaVM Failed...\n);
 
  }
 
  then, when some event echoed I will make a callback of some class in jvm
 
  void _callback()
  {
  JNIEnv *env = NULL;
  int nResult = -1;
 
  *nResult = jvm-AttachCurrentThread((void **)env, NULL);*
  *if ((nResult != 0) || (env == NULL))*
  {
  fprintf(stderr, -- In _Java_com_caval_now_Map_AddItem Thread Attached
  Failed.\n);
  return;
 
  }
 
  jstring ret = env-NewStringUTF(pszTitle); // I run to this line and ap
  crashed.
  jclass cls = env-FindClass(com/caval/now/ServerList);
 
  }
 
  the AttachCurrentThread func return OK and also I get the env pointer.
  but any call on env will crash.
 
  I have no idea of this issue...any help will highly appriciated.
 
  Regards,
  Caval.
 


--~--~-~--~~~---~--~~
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: JNI check failures when trying to use a configured SOCKS Proxy object...

2009-06-22 Thread Billy Cui

I do have the same problem.  Seems android sdk's problem..


On 5月14日, 上午6时16分, fadden fad...@android.com wrote:
 On May 12, 6:53 pm, fadden fad...@android.com wrote:

  Are you including any of your own native code?  If not, this is likely
  a bug in the core libraries.

 ...and so it is.

 OSNetworkSystem.java declares:

static native InetAddress getHostByNameImpl(String addr,
boolean preferIPv6Addresses) throws UnknownHostException;

 That ends up here:

 static jobject osNetworkSystem_getHostByNameImpl(JNIEnv* env, jclass
 clazz,
jstring nameStr, jboolean preferIPv6Addresses) {

 which does this:

jbyteArray addr = env-NewByteArray(4);
  ...
return addr;

 So, it's returning a byte array when an InetAddress object is
 expected.

 I'm not sure what a workaround would be.  For reference, here's the
 stack trace (via a new extension to the Check JNI feature), using
 the provided APK:

 I/InetAddress( 2771): gethostbyaddr: getnameinfo: 192.168.1.4 =
 192.168.1.4
 W/dalvikvm( 2771): JNI WARNING: method declared to return 'Ljava/net/
 InetAddress;' returned '[B'
 W/dalvikvm( 2771):  failed in Lorg/apache/harmony/luni/
 platform/OSNetworkSystem;.getHostByNameImpl
 I/dalvikvm( 2771): main prio=5 tid=3 RUNNABLE
 I/dalvikvm( 2771):   | group=main sCount=0 dsCount=0 s=N
 obj=0x40018e70
 I/dalvikvm( 2771):   | sysTid=2771 nice=0 sched=0/0 handle=-1094144900
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.platform.OSNetworkSystem.getHostByNameImpl
 (Native Method)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.platform.OSNetworkSystem.getHostByName
 (OSNetworkSystem.java:389)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.net.PlainSocketImpl.socksGetServerAddress
 (PlainSocketImpl.java:368)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.net.PlainSocketImpl.socksConnect
 (PlainSocketImpl.java:380)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.net.PlainSocketImpl.connect
 (PlainSocketImpl.java:224)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.net.PlainSocketImpl.connect
 (PlainSocketImpl.java:521)
 I/dalvikvm( 2771):   at java.net.Socket.connect(Socket.java:1019)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.init
 (HttpConnection.java:67)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager
 $ConnectionPool.getHttpConnection(HttpConnectionManager.java:151)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection
 (HttpConnectionManager.java:79)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection
 (HttpURLConnection.java:828)
 I/dalvikvm( 2771):   at
 org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect
 (HttpURLConnection.java:800)
 I/dalvikvm( 2771):   at com.test.socks.Socks5ProxyTest.onStart
 (Socks5ProxyTest.java:103)
 I/dalvikvm( 2771):   at android.app.Instrumentation.callActivityOnStart
 (Instrumentation.java:1205)
 I/dalvikvm( 2771):   at android.app.Activity.performStart
 (Activity.java:3490)
 I/dalvikvm( 2771):   at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
 2302)
 I/dalvikvm( 2771):   at android.app.ActivityThread.handleLaunchActivity
 (ActivityThread.java:2346)
 I/dalvikvm( 2771):   at android.app.ActivityThread.access$1800
 (ActivityThread.java:112)
 I/dalvikvm( 2771):   at android.app.ActivityThread$H.handleMessage
 (ActivityThread.java:1751)
 I/dalvikvm( 2771):   at android.os.Handler.dispatchMessage
 (Handler.java:99)
 I/dalvikvm( 2771):   at android.os.Looper.loop(Looper.java:123)
 I/dalvikvm( 2771):   at android.app.ActivityThread.main
 (ActivityThread.java:4021)
 I/dalvikvm( 2771):   at java.lang.reflect.Method.invokeNative(Native
 Method)
 I/dalvikvm( 2771):   at java.lang.reflect.Method.invoke(Method.java:
 521)
 I/dalvikvm( 2771):   at com.android.internal.os.ZygoteInit
 $MethodAndArgsCaller.run(ZygoteInit.java:841)
 I/dalvikvm( 2771):   at com.android.internal.os.ZygoteInit.main
 (ZygoteInit.java:599)
 I/dalvikvm( 2771):   at dalvik.system.NativeStart.main(Native Method)
 I/dalvikvm( 2771):
 E/dalvikvm( 2771): VM aborting
--~--~-~--~~~---~--~~
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: JNI check failures when trying to use a configured SOCKS Proxy object...

2009-05-13 Thread fadden

On May 12, 6:53 pm, fadden fad...@android.com wrote:
 Are you including any of your own native code?  If not, this is likely
 a bug in the core libraries.

...and so it is.

OSNetworkSystem.java declares:

   static native InetAddress getHostByNameImpl(String addr,
   boolean preferIPv6Addresses) throws UnknownHostException;

That ends up here:

static jobject osNetworkSystem_getHostByNameImpl(JNIEnv* env, jclass
clazz,
   jstring nameStr, jboolean preferIPv6Addresses) {

which does this:

   jbyteArray addr = env-NewByteArray(4);
 ...
   return addr;

So, it's returning a byte array when an InetAddress object is
expected.

I'm not sure what a workaround would be.  For reference, here's the
stack trace (via a new extension to the Check JNI feature), using
the provided APK:

I/InetAddress( 2771): gethostbyaddr: getnameinfo: 192.168.1.4 =
192.168.1.4
W/dalvikvm( 2771): JNI WARNING: method declared to return 'Ljava/net/
InetAddress;' returned '[B'
W/dalvikvm( 2771):  failed in Lorg/apache/harmony/luni/
platform/OSNetworkSystem;.getHostByNameImpl
I/dalvikvm( 2771): main prio=5 tid=3 RUNNABLE
I/dalvikvm( 2771):   | group=main sCount=0 dsCount=0 s=N
obj=0x40018e70
I/dalvikvm( 2771):   | sysTid=2771 nice=0 sched=0/0 handle=-1094144900
I/dalvikvm( 2771):   at
org.apache.harmony.luni.platform.OSNetworkSystem.getHostByNameImpl
(Native Method)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.platform.OSNetworkSystem.getHostByName
(OSNetworkSystem.java:389)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.net.PlainSocketImpl.socksGetServerAddress
(PlainSocketImpl.java:368)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.net.PlainSocketImpl.socksConnect
(PlainSocketImpl.java:380)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.net.PlainSocketImpl.connect
(PlainSocketImpl.java:224)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.net.PlainSocketImpl.connect
(PlainSocketImpl.java:521)
I/dalvikvm( 2771):   at java.net.Socket.connect(Socket.java:1019)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.init
(HttpConnection.java:67)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager
$ConnectionPool.getHttpConnection(HttpConnectionManager.java:151)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection
(HttpConnectionManager.java:79)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection
(HttpURLConnection.java:828)
I/dalvikvm( 2771):   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect
(HttpURLConnection.java:800)
I/dalvikvm( 2771):   at com.test.socks.Socks5ProxyTest.onStart
(Socks5ProxyTest.java:103)
I/dalvikvm( 2771):   at android.app.Instrumentation.callActivityOnStart
(Instrumentation.java:1205)
I/dalvikvm( 2771):   at android.app.Activity.performStart
(Activity.java:3490)
I/dalvikvm( 2771):   at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2302)
I/dalvikvm( 2771):   at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:2346)
I/dalvikvm( 2771):   at android.app.ActivityThread.access$1800
(ActivityThread.java:112)
I/dalvikvm( 2771):   at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1751)
I/dalvikvm( 2771):   at android.os.Handler.dispatchMessage
(Handler.java:99)
I/dalvikvm( 2771):   at android.os.Looper.loop(Looper.java:123)
I/dalvikvm( 2771):   at android.app.ActivityThread.main
(ActivityThread.java:4021)
I/dalvikvm( 2771):   at java.lang.reflect.Method.invokeNative(Native
Method)
I/dalvikvm( 2771):   at java.lang.reflect.Method.invoke(Method.java:
521)
I/dalvikvm( 2771):   at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:841)
I/dalvikvm( 2771):   at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:599)
I/dalvikvm( 2771):   at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm( 2771):
E/dalvikvm( 2771): VM aborting

--~--~-~--~~~---~--~~
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: JNI check failures when trying to use a configured SOCKS Proxy object...

2009-05-12 Thread fadden

On May 11, 4:58 pm, AndyK akisp...@gmail.com wrote:
 I'm trying to write a simple application that will utilize a Socks5
 proxy server to connect to a web server (www.google.com).  I am using
 an instance of 'java.net.Proxy' of type 'SOCKS' in my application and
 am using my implementation of ProxySelector.  I can see from the
 logcat output that my implementation of ProxySelector is being called
 and will passback a list containing one Proxy instance.  When I run
 this code in the emulator, I consistently get a JNI check error
 resulting in the VM aborting.  I have attempted to run this
 application with recent public releases of the SDK, all resulting in
 the same behavior, JNI check failure and VM abort.

Are you including any of your own native code?  If not, this is likely
a bug in the core libraries.

Can you send me an APK that demonstrates the behavior?

FWIW, some bit of code is trying to access a field in a byte array,
which doesn't work very well since byte arrays don't have fields.  I
wasn't able to convert the native stack trace you posted to symbolic
form.  If I have a reproducible case it'll be easy to figure out.

--~--~-~--~~~---~--~~
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: JNI run time error even I use same code and lib as Android source code.

2009-02-27 Thread yichu

I got it:

http://groups.google.com/group/android-developers/browse_thread/thread/d80b1157cda06a79/7f6a3fee79713011

On Feb 26, 11:19 pm, yichu chuuw...@gmail.com wrote:
 Hi Jerry,

 Could you share how to fix thisjni_onloadproblem? I got the same
 error but don't know how to solve it. Thanks :)

 Yichu

 On Feb 24, 12:45 am, Jerry Yang 1999bige...@gmail.com wrote:

  Hi, all
  I checked the logcat, I find it cannot find thejni_Onload,
  Thanks for your information, I find I forget the functionjni_Onloadmethod,
  it is a new requirement after jni)1.2
  Now my hello world working.
  Thanks
  With best wishes
  Jerry

  On Mon, Feb 23, 2009 at 11:38 PM, Jerry Yang 1999bige...@gmail.com wrote:
   Hi, Marco and all
   Here is the log:

   D/AndroidRuntime( 1221):
   D/AndroidRuntime( 1221):  AndroidRuntime START 
   
   D/AndroidRuntime( 1221): CheckJNI is OFF
   I/ActivityThread( 1223): Publishing provider
   com.android.vending.SuggestionsProv
   ider: com.android.vending.SuggestionsProvider
   D/AndroidRuntime( 1221): --- registering native functions ---
   I/jdwp    ( 1221): received file descriptor 23 from ADB
   I/ActivityManager(   52): Stopping service:
   com.android.vending/.LocalDbSyncServ
   ice
   I/ActivityManager(   52): Starting activity: Intent { flags=0x1000
   comp={com
   .android.hello/com.android.hello.HelloAndroid} }
   I/ActivityManager(   52): Start proc com.android.hello for activity
   com.android.
   hello/.HelloAndroid: pid=1240 uid=10023 gids={}
   D/AndroidRuntime( 1221): Shutting down VM
   D/dalvikvm( 1221): DestroyJavaVM waiting for non-daemon threads to exit
   I/dalvikvm( 1221): DestroyJavaVM shutting VM down
   D/dalvikvm( 1221): HeapWorker thread shutting down
   D/dalvikvm( 1221): HeapWorker thread has shut down
   D/jdwp    ( 1221): JDWP shutting down net...
   D/jdwp    ( 1221): +++ peer disconnected
   I/dalvikvm( 1221): Debugger has detached; object registry had 1 entries
   D/dalvikvm( 1221): VM cleaning up
   D/dalvikvm( 1221): LinearAlloc 0x0 used 541332 of 4194304 (12%)
   I/jdwp    ( 1240): received file descriptor 10 from ADB
   D/dalvikvm( 1240): Trying to load lib /system/lib/libhello.so 0x433b50d8
   D/dalvikvm( 1240): Added shared lib /system/lib/libhello.so 0x433b50d8
   D/dalvikvm( 1240):NoJNI_OnLoadfoundin /system/lib/libhello.so
   0x433b50d8
   W/ActivityManager(   52): Activity pause timeout for 
   HistoryRecord{435ae750
   {com.android.hello/com.android.hello.HelloAndroid}}
   I/ActivityManager(   52): Displayed activity
   com.android.hello/.HelloAndroid: 2025 ms
   I/ActivityManager(   52): Stopping service:
   com.android.vending/.PackageMonitorReceiver$UpdateCheckinDatabaseService
   D/dalvikvm(   90): GC freed 2431 objects / 127176 bytes in 276ms
   D/dalvikvm( 1223): GC freed 2076 objects / 140976 bytes in 128ms
   With best wishes
   Jerry

   On Tue, Feb 24, 2009 at 1:36 AM, Marco Nelissen 
   marc...@android.comwrote:

   On Sun, Feb 22, 2009 at 10:23 PM, Jerry Yang 1999bige...@gmail.com
   wrote:
   (...)
3. push the .apk to the phone and run from eclips
 always a run time error like:the application hello.android has 
stopped
unexpectedly, pla try again

   What does it say in the system log?
--~--~-~--~~~---~--~~
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: JNI - FindClass() returns null

2009-01-13 Thread Andrew Stadler

As has been noted before, native code  JNI development is not
currently supported on the SDK, and probably is better off discussed
in the android-platform or android-discuss boards.

See http://source.android.com/discuss for more information.

--~--~-~--~~~---~--~~
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: JNI - FindClass() returns null

2009-01-12 Thread Dave Sparks

Of the top of my head, I think you need to createThreadEtc with the
flag to indicate that your thread will call into Java.

On Jan 9, 2:00 pm, redlight9...@gmail.com redlight9...@gmail.com
wrote:
 i am trying to make callbacks to my android application from a native
 C thread using JNI.  however when i call FindClass it returns a NULL
 value.   i need to get the jclass value returned by FindClass() to
 call GetStaticMethoID to make calls back up to my android application.

 i store the JavaVM* globally that i receive from JNI_OnLoad which gets
 called from the android thread when my application loads my shared
 library.  I then use that JavaVM* to attach the java virtual machine
 to my native C thread by calling AttachCurrentThread() which returns a
 0 value indicating success.

 the weird thing is that when i make calls to FindClass() in the
 android thread it works fine and returns a valid value.  however when
 i call FindClass() from the native C thread it returns NULL.  I was
 thinking that it might have something to do with the native C thread
 not have the proper classpath set up?  any help would be greatly
 appreciated.

 my code is down below, i omitted error checking and some of the code
 to save space.

 #include JNIHelp.h
 #include jni.h
 #include utils/Log.h

 static JavaVM *jvm;

 static void androidCback(int event)
 {
 jint r;
 jclass cls;
 JNIEnv *env;
 jmethodID mid;

 r = (*jvm)-AttachCurrentThread(jvm, env, NULL);

 /* !!! FindClass returns NULL !!! */
 cls = (*env)-FindClass(env, com.android.SomeApp.Class);

 mid = (*env)-GetStaticMethodID(env, cls, handleEvent, (I)V);
 (*jvm)-DetachCurrentThread(jvm);

 }

 JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)

 {

 JNIEnv *env;

 JNINativeMethod meth;

 jclass k;

 jint r;

 r = (*vm)-GetEnv (vm, (void **) env, JNI_VERSION_1_4);

 /* !!! FindClass returns valid value !!! */
 k = (*env)-FindClass (env, com.android.SomeApp.Class);

 /* save the java virtual machine globally */
 jvm = vm;

 meth.name = enableNative;

 meth.signature = (I)Z;

 meth.fnPtr = enableNative;

 r = (*env)-RegisterNatives (env, k, meth, 1);

 }

 JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved)

 {

 JNIEnv *env;

 jclass k;

 jint r;

 r = (*vm)-GetEnv (vm, (void **) env, JNI_VERSION_1_4);

 /* !!! FindClass returns valid value !!! */
 k = (*env)-FindClass (env, com.android.SomeApp.Class);

 (*env)-UnregisterNatives(env, k);

 }
--~--~-~--~~~---~--~~
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: JNI - FindClass() returns null

2009-01-12 Thread fadden

On Jan 9, 2:00 pm, redlight9...@gmail.com redlight9...@gmail.com
wrote:
 i am trying to make callbacks to my android application from a native
 C thread using JNI.  however when i call FindClass it returns a NULL
 value.   i need to get the jclass value returned by FindClass() to
 call GetStaticMethoID to make calls back up to my android application.

How is androidCback() getting called?

The class loader that FindClass uses is the same as the class loader
associated with the current native method.  If there's no Java-visible
native method on the call stack, because you just attached the thread
through JNI, it will use the system class loader, which has access
to the Android classes but not to anything app-specific.  (Android
apps are loaded by a user-defined class loader, not the system /
application / CLASSPATH class loader.)  There is one exception to
this rule: in JNI_OnLoad, we use the class loader associated with the
shared lib itself, which is why it works there.

You can see some similar anguish in the runtime startup -- frameworks/
base/core/jni/AndroidRuntime.cpp, AndroidRuntime::findClass(), has a
related problem because the calling method comes out of the bootstrap
class loader and thus the FindClass is very limited in scope.

Your best bet here is probably to do the class lookup at JNI_OnLoad
time, call NewGlobalRef to make it a global reference, and cache it
locally.  You could also cache a copy of the class loader for future
lookups (see the findClass() mentioned above for an example of calling
loadClass() on a ClassLoader object).

See also FindClass in the JNI ref:
http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp16027

--~--~-~--~~~---~--~~
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: JNI

2009-01-08 Thread blues

Thanks.

I tried System.loadLibrary(mylib);
I got exception of unsatisfied link.

I tried both my lib (libmylib.so) and some libs under /system/lib.
Both Dev1 and G1 phones.

On Jan 7, 7:13 pm, Dave Sparks davidspa...@android.com wrote:
 You can download the Android source code from source.android.com and
 build yourJNIlibraries against the gcc toolchain for testing.

 On Jan 5, 5:19 pm, blues bluescapt...@gmail.com wrote:



  I have read all the post aboutJNI. And I knowJNIis not offcially
  supported and google is working on the native SDK and I have to wait.

  But I really want to verify the performance of the native code now so
  I can know which direction to go before the native SDK release.

  So may I know if the G1 or DEV 1 phone supportJNI? Just for test
  purpose on my own phone.

  Blues- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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: JNI

2009-01-08 Thread Dianne Hackborn
Since native code is not currently supported in the SDK, could you please
move this to one of the platform lists?  Thanks.

Btw if you read the platform lists, there is now in the main tree a complete
example of implementing a native code library and a Java glue library that
uses JNI to call it.

On Thu, Jan 8, 2009 at 1:05 PM, blues bluescapt...@gmail.com wrote:


 Thanks.

 I tried System.loadLibrary(mylib);
 I got exception of unsatisfied link.

 I tried both my lib (libmylib.so) and some libs under /system/lib.
 Both Dev1 and G1 phones.

 On Jan 7, 7:13 pm, Dave Sparks davidspa...@android.com wrote:
  You can download the Android source code from source.android.com and
  build yourJNIlibraries against the gcc toolchain for testing.
 
  On Jan 5, 5:19 pm, blues bluescapt...@gmail.com wrote:
 
 
 
   I have read all the post aboutJNI. And I knowJNIis not offcially
   supported and google is working on the native SDK and I have to wait.
 
   But I really want to verify the performance of the native code now so
   I can know which direction to go before the native SDK release.
 
   So may I know if the G1 or DEV 1 phone supportJNI? Just for test
   purpose on my own phone.
 
   Blues- Hide quoted text -
 
  - Show quoted text -
 



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~-~--~~~---~--~~
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: JNI

2009-01-08 Thread blues

Sorry, I cannot figure out a way to move this thread to the platform
list.
So I have to post here for now. And maybe more people will go this
list and try to find a answer about JNI?

And I searched the platform list by keyword jni, but didn't find the
complete example.
Anyone can help to give a link here? Thanks.

On Jan 8, 1:11 pm, Dianne Hackborn hack...@android.com wrote:
 Since native code is not currently supported in the SDK, could you please
 move this to one of the platform lists?  Thanks.

 Btw if you read the platform lists, there is now in the main tree a complete
 example of implementing a native code library and a Java glue library that
 uses JNI to call it.





 On Thu, Jan 8, 2009 at 1:05 PM, blues bluescapt...@gmail.com wrote:

  Thanks.

  I tried System.loadLibrary(mylib);
  I got exception of unsatisfied link.

  I tried both my lib (libmylib.so) and some libs under /system/lib.
  Both Dev1 and G1 phones.

  On Jan 7, 7:13 pm, Dave Sparks davidspa...@android.com wrote:
   You can download the Android source code from source.android.com and
   build yourJNIlibraries against the gcc toolchain for testing.

   On Jan 5, 5:19 pm, blues bluescapt...@gmail.com wrote:

I have read all the post aboutJNI. And I knowJNIis not offcially
supported and google is working on the native SDK and I have to wait.

But I really want to verify the performance of the native code now so
I can know which direction to go before the native SDK release.

So may I know if the G1 or DEV 1 phone supportJNI? Just for test
purpose on my own phone.

Blues- Hide quoted text -

   - Show quoted text -

 --
 Dianne Hackborn
 Android framework engineer
 hack...@android.com

 Note: please don't send private questions to me, as I don't have time to
 provide private support.  All such questions should be posted on public
 forums, where I and others can see and answer them.- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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: JNI

2009-01-08 Thread Dianne Hackborn
Please just post on the platform list.  This is not the place to discuss
JNI.

On Thu, Jan 8, 2009 at 1:28 PM, blues bluescapt...@gmail.com wrote:


 Sorry, I cannot figure out a way to move this thread to the platform
 list.
 So I have to post here for now. And maybe more people will go this
 list and try to find a answer about JNI?

 And I searched the platform list by keyword jni, but didn't find the
 complete example.
 Anyone can help to give a link here? Thanks.

 On Jan 8, 1:11 pm, Dianne Hackborn hack...@android.com wrote:
  Since native code is not currently supported in the SDK, could you please
  move this to one of the platform lists?  Thanks.
 
  Btw if you read the platform lists, there is now in the main tree a
 complete
  example of implementing a native code library and a Java glue library
 that
  uses JNI to call it.
 
 
 
 
 
  On Thu, Jan 8, 2009 at 1:05 PM, blues bluescapt...@gmail.com wrote:
 
   Thanks.
 
   I tried System.loadLibrary(mylib);
   I got exception of unsatisfied link.
 
   I tried both my lib (libmylib.so) and some libs under /system/lib.
   Both Dev1 and G1 phones.
 
   On Jan 7, 7:13 pm, Dave Sparks davidspa...@android.com wrote:
You can download the Android source code from source.android.com and
build yourJNIlibraries against the gcc toolchain for testing.
 
On Jan 5, 5:19 pm, blues bluescapt...@gmail.com wrote:
 
 I have read all the post aboutJNI. And I knowJNIis not offcially
 supported and google is working on the native SDK and I have to
 wait.
 
 But I really want to verify the performance of the native code now
 so
 I can know which direction to go before the native SDK release.
 
 So may I know if the G1 or DEV 1 phone supportJNI? Just for test
 purpose on my own phone.
 
 Blues- Hide quoted text -
 
- Show quoted text -
 
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support.  All such questions should be posted on public
  forums, where I and others can see and answer them.- Hide quoted text -
 
  - Show quoted text -
 



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~-~--~~~---~--~~
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: JNI

2009-01-07 Thread Dave Sparks

You can download the Android source code from source.android.com and
build your JNI libraries against the gcc toolchain for testing.

On Jan 5, 5:19 pm, blues bluescapt...@gmail.com wrote:
 I have read all the post about JNI. And I know JNI is not offcially
 supported and google is working on the native SDK and I have to wait.

 But I really want to verify the performance of the native code now so
 I can know which direction to go before the native SDK release.

 So may I know if the G1 or DEV 1 phone support JNI? Just for test
 purpose on my own phone.

 Blues
--~--~-~--~~~---~--~~
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: JNI support in 1.0

2008-10-05 Thread Neil . He
What about the development of a hardware driver or middle wire on android?
2008/9/30 hackbod [EMAIL PROTECTED]


 To be clear: native code is not a supported part of the 1.0 SDK.  If
 you use it, your application will most likely break with future
 platform updates.

 On Sep 29, 8:48 am, Josh Guilfoyle [EMAIL PROTECTED] wrote:
  I haven't specifically tested with 1.0, but with 0.9r1 it was
  certainly possible.  The issue of it being supported, however, is more
  difficult.  There is no distribution mechanism for native code,
  furthermore the /system image is not writable on normal phones.  So
  unless there is a way to load native code from /data (I can't say one
  way or another; haven't tried), it's certainly going to be out of
  reach for any typical user to install.  Even still, it will require
  some moderate sophistication to install apps that use native code, and
  they won't be available on the Market which is probably a big
  deterrent for most users.
 
  On Sep 29, 12:15 am, wiki [EMAIL PROTECTED] wrote:
 
   HI,
   does Android supports JNI?
   I see the loadLibrary() function available in the System. but came
   across certain discussion that Native code is not supported in Android
   1.0.
   can somebody clear the picture please?
 
   Regards
   wiki
 



-- 
Best Regards
Neil.He
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: JNI support in 1.0

2008-10-05 Thread Ahmet A. Akin

middle wire.. sounds funny.

On Sun, Oct 5, 2008 at 11:52 PM, Neil. He [EMAIL PROTECTED] wrote:
 What about the development of a hardware driver or middle wire on android?
 2008/9/30 hackbod [EMAIL PROTECTED]

 To be clear: native code is not a supported part of the 1.0 SDK.  If
 you use it, your application will most likely break with future
 platform updates.

 On Sep 29, 8:48 am, Josh Guilfoyle [EMAIL PROTECTED] wrote:
  I haven't specifically tested with 1.0, but with 0.9r1 it was
  certainly possible.  The issue of it being supported, however, is more
  difficult.  There is no distribution mechanism for native code,
  furthermore the /system image is not writable on normal phones.  So
  unless there is a way to load native code from /data (I can't say one
  way or another; haven't tried), it's certainly going to be out of
  reach for any typical user to install.  Even still, it will require
  some moderate sophistication to install apps that use native code, and
  they won't be available on the Market which is probably a big
  deterrent for most users.
 
  On Sep 29, 12:15 am, wiki [EMAIL PROTECTED] wrote:
 
   HI,
   does Android supports JNI?
   I see the loadLibrary() function available in the System. but came
   across certain discussion that Native code is not supported in Android
   1.0.
   can somebody clear the picture please?
 
   Regards
   wiki




 --
 Best Regards
 Neil.He
 [EMAIL PROTECTED]

 


--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: JNI support in 1.0

2008-09-29 Thread Josh Guilfoyle

I haven't specifically tested with 1.0, but with 0.9r1 it was
certainly possible.  The issue of it being supported, however, is more
difficult.  There is no distribution mechanism for native code,
furthermore the /system image is not writable on normal phones.  So
unless there is a way to load native code from /data (I can't say one
way or another; haven't tried), it's certainly going to be out of
reach for any typical user to install.  Even still, it will require
some moderate sophistication to install apps that use native code, and
they won't be available on the Market which is probably a big
deterrent for most users.

On Sep 29, 12:15 am, wiki [EMAIL PROTECTED] wrote:
 HI,
 does Android supports JNI?
 I see the loadLibrary() function available in the System. but came
 across certain discussion that Native code is not supported in Android
 1.0.
 can somebody clear the picture please?

 Regards
 wiki
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: JNI support in 1.0

2008-09-29 Thread hackbod

To be clear: native code is not a supported part of the 1.0 SDK.  If
you use it, your application will most likely break with future
platform updates.

On Sep 29, 8:48 am, Josh Guilfoyle [EMAIL PROTECTED] wrote:
 I haven't specifically tested with 1.0, but with 0.9r1 it was
 certainly possible.  The issue of it being supported, however, is more
 difficult.  There is no distribution mechanism for native code,
 furthermore the /system image is not writable on normal phones.  So
 unless there is a way to load native code from /data (I can't say one
 way or another; haven't tried), it's certainly going to be out of
 reach for any typical user to install.  Even still, it will require
 some moderate sophistication to install apps that use native code, and
 they won't be available on the Market which is probably a big
 deterrent for most users.

 On Sep 29, 12:15 am, wiki [EMAIL PROTECTED] wrote:

  HI,
  does Android supports JNI?
  I see the loadLibrary() function available in the System. but came
  across certain discussion that Native code is not supported in Android
  1.0.
  can somebody clear the picture please?

  Regards
  wiki
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---