Native apps

Trying to further the development of the Android on the Revue? Talk about it hear and document it on the wiki: http://www.wiki.gtvhacker.com

Moderator: Revue Mod

Post Reply
danips
Android 1.0
Posts: 1
Joined: Fri Jul 29, 2011 3:14 am
Location: Vigo, Spain

Native apps

Post by danips »

Hi, I am trying to port native code that already worked in 2.1 to Honeycomb. I know this kind of apps won't be available in the market, but my app is for demonstration purposes only.

I have found that you must place your .so libraries in /libs/none/.
When I try to launch the simplest app: hello-jni, it tells it cannot find libc.so:
10-13 17:54:26.116: WARN/dalvikvm(9834): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/hellojni/HelloJni;
10-13 17:54:26.116: WARN/dalvikvm(9834): Class init failed in newInstance call (Lcom/example/hellojni/HelloJni;)
10-13 17:54:26.116: DEBUG/AndroidRuntime(9834): Shutting down VM
10-13 17:54:26.116: WARN/dalvikvm(9834): threadid=1: thread exiting with uncaught exception (group=0x66ac9778)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): FATAL EXCEPTION: main
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): java.lang.ExceptionInInitializerError
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at java.lang.Class.newInstanceImpl(Native Method)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at java.lang.Class.newInstance(Class.java:1301)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1683)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.app.ActivityThread.access$1500(ActivityThread.java:124)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1016)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.os.Handler.dispatchMessage(Handler.java:99)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.os.Looper.loop(Looper.java:132)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at android.app.ActivityThread.main(ActivityThread.java:4083)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at java.lang.reflect.Method.invokeNative(Native Method)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at java.lang.reflect.Method.invoke(Method.java:491)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at dalvik.system.NativeStart.main(Native Method)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): Caused by: java.lang.UnsatisfiedLinkError: libc.so: cannot open shared object file: No such file or directory
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at java.lang.Runtime.loadLibrary(Runtime.java:430)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at java.lang.System.loadLibrary(System.java:554)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): at com.example.hellojni.HelloJni.<clinit>(HelloJni.java:64)
10-13 17:54:26.120: ERROR/AndroidRuntime(9834): ... 15 more
I can see a libc-2.12.2.so and libc.so.6 (a link to libc-2.12.2.so), in /lib using ./adb shell; I think I would only need to make a new link with the required name. Is it possible to make this link in the filesystem?

I have even tried to use an extracted libc.so inside the apk and load it before my .so with no success.

Anyone has gone any step further?
mcd2000
Ice Cream Sandwich
Posts: 459
Joined: Wed Aug 03, 2011 5:52 am
GTV Device Owned: Vizio Co-Star
Location: Russia, Saint-Petersburg
Contact:

Re: Native apps

Post by mcd2000 »

Heh. I am on the same step now. The problem is not only in this lib, but about almost every standard lib. I suppose, when NDK will be officially supported, all required symlinks will appear.
ViMu Player
ViMu/GTVBox Google+ page
My devices: Logitech Revue, Sony NSZ-GT1, Sony NSZ-GS7, Vizio Co-Star, Hisense Pulse (rooted), ASUS Qube and some others...
hharte
Android 1.0
Posts: 8
Joined: Sat Aug 06, 2011 10:47 am

Re: Native apps

Post by hharte »

See my other post about the NDK. You can statically link, but then you need to build static versions of all required libraries.

-Howard
-Howard

---
MagicAndroidApps.com - Home of Better Terminal Emulator Pro, now supporting Google TV.
Post Reply