4

My job is android framework porting.

I got a lot of 3rd APK can't run on my Android Jelly Bean. (All of them are linker to libmono.so)

All of them are failed in JNI_OnLoad() function in libmono.so when they was runing. Below are my error log and analysis.

//1. Android dalvik vm native.cpp ( dvmLoadNativeCode(){ ...dlopen()...})

**D/dalvikvm(2629): Added shared lib /data/data/pl.idreams.jellydefense/lib/libmono.so 0xaed3a578**

//2. Android linker load libmono.so and return JNI_OnLoad function address // Android dalvik vm native.cpp ( dvmLoadNativeCode(){ ...dlsym(handle, "JNI_OnLoad")...})

**D/linker(2629): TRACE:  1252 SEARCH JNI_OnLoad in libmono.so@0xa5cf9000 0467e784 86**
**D/linker(2629): TRACE:  1252 FOUND JNI_OnLoad in libmono.so (0000a3a4) 340**

//3. Android dalvik vm native.cpp ( dvmLoadNativeCode(){ ..version = (*func)(gDvmJni.jniVm, NULL);..}) // execute JNI_OnLoad function and return JNI version, libmono dump below error message

**E/linker(2629): ERROR: OOPS:     0 cannot map library 'libmono.so'. no vspace available.**

//4. libmono return JNI version = 0

**W/dalvikvm(2629): JNI_OnLoad returned bad version (0) in /data/data/pl.idreams.jellydefense/lib/libmono.so 0xaed3a578**

Can someone tell me why JNI_OnLoad failed in Libmono.so?

What does JNI_OnLoad do in Libmono.so? (Does I lose some module or share library?)

Thanks a lot, Chin ku

user1650520
  • 41
  • 1
  • 2
  • 1
    Have you altered the `adb logcat` output in any way? Mono for Android apps don't use `libmono.so`, so I don't know why that would be appearing in your logcat output. Assuming you're doing `s/libmonodroid/libmono/g`, `libmonodroid.so!JNI_OnLoad()` will return `0` if you try to run the evaluation version on hardware, with a message: "ERROR: This version of MonoDroid will only run in the Android emulator". – jonp Sep 10 '12 at 18:17

1 Answers1

1

It looks like your application is trying to allocate too much memory and Android has had enough. The cause is not necessarily your libmono.so (or the class that loads it, though these could be the culpurit), it just happens to occur during the loading of that library.

The JNI_OnLoad() function of a native library returns a JNI version to indicate it is able to proceed, or 0 if it determined it cannot proceed. It looks like a failing allocation is leading to it returning 0 to indicate it could not initialize and so cannot be used.

As to "cannot map library 'libmono.so'. no vspace available." -- this is an open source project, right? I would imagine you will have no trouble locating the JNI_OnLoad source to answer that yourself.

mah
  • 39,056
  • 9
  • 76
  • 93