I tried out what Volker suggested. My test results is as following:
Can someone advice with the part that I make native function calls?
1. I added the following code to android application
Lunarlander.java
//native method declaration
native void hello(String name);
static {
System.out.println("libhello.so loaded");
System.load("/data/app/libhello.so");
}
I added my libhellp.so to lunalander.apk and then uploaded the apk to /
data/app. The application launches ok.
2. I added the following code to android application
Lunarlander.java
//native method declaration
native void hello(String name);
static {
System.out.println("libhello.so loaded");
System.load("/data/app/libhello.so");
}
…
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
…
//test loading hello lib and call hello function
LunarLander myLunarLander = new LunarLander();
myLunarLander.hello("Hi there!");
…
}
I added my libhellp.so to lunalander.apk and then uploaded the apk to /
data/app. The application launches was forced to close and the error
message is “The application Lunar lander has stopped unexpectedly.
Please try again”.
On Nov 7, 3:22 am, "pasquale.anatriello"
<[EMAIL PROTECTED]> wrote:
> I would like to know this too.
> We are willing to port our project in android too but we have all our
> HUGE library written in C.
> Is there a hope to have a native support soon enough?
> Is it official that this support will be relased?
> We managed to run some code on the Emulator but as it is now it's not
> possible to run native code on the device without hacking it
> Thank you for your patience (and sorry for my poor english)
> Pasquale Anatriello
>
> On 21 Ott, 19:37, StephC <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 1 oct, 17:23, "Romain Guy" <[EMAIL PROTECTED]> wrote:
>
> > > First of all,JNIis not used in our apps. Only in the framework.
> > > Then, we are working on a native SDK that will provide official and
> > > correct support forJNI. Just be patient :)
>
> > This is very good news for games developers!
>
> > We're working on Augmented Reality games with real time image analysis
> > not doable inside a VM.
>
> > We'll be glad to port it on the Android platform.
>
> > How long will we have to wait for this native SDK?
>
> > > On Wed, Oct 1, 2008 at 2:53 AM, MrSnowflake <[EMAIL PROTECTED]> wrote:
>
> > > > I believeJNIis not supported for developers, because 1: It would
> > > > require developers to build libs for every different android platform
> > > > out and 2: While Google (probably) usesJNI, they can just change the
> > > >JNIinterface and fix their code, but say if youJNIable program
> > > > works on SDK 1.0r1 and then suddenly, when r2 gets released (and
> > > > Google changed theJNI) your program wouldn't work anymore. This is
> > > > something google really wants to avoid.
>
> > > > On 1 okt, 11:42, Tauno T <[EMAIL PROTECTED]> wrote:
> > > >> Oh, sorry, I misunderstood you there :)
>
> > > >> On Oct 1, 12:37 pm, Volker Gropp <[EMAIL PROTECTED]> wrote:
>
> > > >> > Hi,
>
> > > >> > you may call it unfair of course. But please keep in mind, they did
> > > >> > not tell us that they use it in their apps. But they use it in their
> > > >> > API to delegate calls to native libs.
>
> > > >> > Regards
> > > >> > Volker
>
> > > >> > On Oct 1, 11:18 am, Tauno T <[EMAIL PROTECTED]> wrote:
>
> > > >> > > Isn't it a little .. how do I say it.. unfair to tell us thatJNIis
> > > >> > > not supported at all and then use it in their own apps to make them
> > > >> > > better and give them more features than are available to the rest
> > > >> > > of
> > > >> > > the developers?
>
> > > >> > > On Oct 1, 11:49 am, Volker Gropp <[EMAIL PROTECTED]> wrote:
>
> > > >> > > > Hi Ranjeet,
>
> > > >> > > > although I'm not the Android Dev Team i can tell you what ive
> > > >> > > > been
> > > >> > > > told last weeks about this topic:JNIis currently not supported in
> > > >> > > > SDK 1.0. The reason is not quite clear, some say cause it may
> > > >> > > > not work
> > > >> > > > at all, or may break in the (near) future. Plus your app wont be
> > > >> > > > portable and needs special versions for every hw platform.
> > > >> > > > Actually i
> > > >> > > > bet Android Dev Team will just tell you: "native libs andJNIis
> > > >> > > > not
> > > >> > > > supported!".
>
> > > >> > > > On the other handJNIis working and Android uses it internally a
> > > >> > > > lot
> > > >> > > > [google talks]. But you may have problems to link against the
> > > >> > > > stripped
> > > >> > > > down libc they are using, or may run into other problems you
> > > >> > > > cannot
> > > >> > > > resolve. Plus please keep in mind there is no real solution to
> > > >> > > > deploy
> > > >> > > > your app on real phones, because /system/lib is read only. You
> > > >> > > > might
> > > >> > > > add your .so into the apk as a raw resource and extract it into
> > > >> > > > your
> > > >> > > > app writable directory under /data. Loading the .so works for me
> > > >> > > > using
> > > >> > > > System.load(). But this way the .so is stored on your phone in 2
> > > >> > > > locations, using a lot unnecessary space.
>
> > > >> > > > Currently for a real world app on real phones i would'nt
> > > >> > > > useJNIand
> > > >> > > > native libs at all due to those problems. Either wait
> > > >> > > > forJNIsupport
> > > >> > > > in future SDK versions or port your library to Java.
>
> > > >> > > > Regards
> > > >> > > > Volker
>
> > > >> > > > On Oct 1, 4:02 am, Ranjeet <[EMAIL PROTECTED]> wrote:
>
> > > >> > > > > Dear Android Dev Team,
>
> > > >> > > > > My apologies if I am asking a question that's already been
> > > >> > > > > answered.
> > > >> > > > > Unfortunately I haven't been able to find any documentation
> > > >> > > > > within
> > > >> > > > > Android's reference that officially states Google's position
> > > >> > > > > on usage
> > > >> > > > > ofJNI/SharedObjects (written in C++ and compiled via a cross
> > > >> > > > > compiler) from within Java ui code. To clarify what I am
> > > >> > > > > trying to
> > > >> > > > > accomplish, we are building an application with the user
> > > >> > > > > interface
> > > >> > > > > completely written using the java/android classes/controls and
> > > >> > > > > it
> > > >> > > > > would use the shared library thats written in C++. There is
> > > >> > > > > just so
> > > >> > > > > much effort gone in to making that library that it would be a
> > > >> > > > > LOT of
> > > >> > > > > effort on our side rewriting it in Java. The library connects
> > > >> > > > > to our
> > > >> > > > > backend web server to fetch XML files over HTTP, stores some
> > > >> > > > > of the
> > > >> > > > > information from it on disk in files, and exposes the features
> > > >> > > > > via
> > > >> > > > > methods.
>
> > > >> > > > > Is this currently "officially supported" in Android(I have
> > > >> > > > > seen hello
> > > >> > > > > world C++ apps that run on the emulator with some
> > > >> > > > > security/chmod
> > > >> > > > > tweaks).
> > > >> > > > > Any information is sincerely appreciated.
>
> > > >> > > > > Thanks,
> > > >> > > > > -Ranjeet
>
> > > --
> > > Romain Guywww.curious-creature.org- 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---