kidok / protobuf

Automatically exported from code.google.com/p/protobuf
0 stars 0 forks source link

protobuf shared library works well in android 2.3(NDK), but can not work on Android 2.1(NDK) and 2.2NDK #326

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.I compiled protobuf(version 2.4.1) to libprotubuf.so with 
NDKr5+cygwin+windows XP.
2.In java code, load this libprotobuf.so like this:   
System.loadLibrary("protobuffull");
3.run my test code to use protobuf.

What is the expected output? What do you see instead?
When I run my test code in android 2.3, it worked very well, load 
libprotobuf.so and then run my test code correctly.
But when I run the code in android 2.1, I found that I can't load 
libprotobuf.so. The logcat showed that it stopped when I try to load 
libprotubuf.so .

What version of the product are you using? On what operating system?
the version of protobuf is 2.4.1, the cell phone os is android 2.1 ,2.2 and 2.3.

Please provide any additional information below.
1. Android.mk:

...
...
..
                google/protobuf/io/zero_copy_stream_impl.cc \
                   google/protobuf/io/zero_copy_stream_impl_lite.cc 

LOCAL_CPP_EXTENSION := .cc

LOCAL_C_INCLUDES := $(LOCAL_PATH)/google/protobuf/io \
                    $(LOCAL_PATH)/google/protobuf/stubs \
                    $(LOCAL_PATH)/google/protobuf \
                    $(LOCAL_PATH)/google/protobuf/compiler \
                    $(LOCAL_PATH)
LOCAL_LDLIBS := -lz                

include $(BUILD_SHARED_LIBRARY)

2. load the shared lib in java code :

System.loadLibrary("protobuffull"); //(it doesn't work in android 2.1 2.2 cell 
phone, but it works well in android 2.3 cell phone)

Original issue reported on code.google.com by nki...@gmail.com on 23 Aug 2011 at 6:45

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I build a protobuf-lite version . Then it worked very well on android 2.1 and 
2.2, but on android 2.3 ,it carshed .......so strange .....

when it run System.loadLibrary("protobuflite");

then it crashed.. here is the logcat

08-25 15:04:37.688: ERROR/cocosdenshion(7816): "begin to load protobuflite ..."
08-25 15:04:37.708: INFO/wpa_supplicant(5513): Reset vh_switch_counter due to 
receive LINKSPEED cmd
08-25 15:04:37.708: WARN/dalvikvm(7816): Exception 
Ljava/lang/UnsatisfiedLinkError; thrown while initializing 
Lcom/JCAmbitionAndroid/JCAmbitionAndroid;
08-25 15:04:37.708: WARN/dalvikvm(7816): Class init failed in newInstance call 
(Lcom/JCAmbitionAndroid/JCAmbitionAndroid;)
08-25 15:04:37.708: DEBUG/AndroidRuntime(7816): Shutting down VM
08-25 15:04:37.708: WARN/dalvikvm(7816): threadid=1: thread exiting with 
uncaught exception (group=0x4001d5a0)
08-25 15:04:37.708: DEBUG/ConnectivityService(25014): getMobileDataEnabled 
returning false
08-25 15:04:37.738: WARN/dalvikvm(17379): disableGcForExternalAlloc: false
08-25 15:04:37.738: ERROR/AndroidRuntime(7816): FATAL EXCEPTION: main
08-25 15:04:37.738: ERROR/AndroidRuntime(7816): 
java.lang.ExceptionInInitializerError
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
java.lang.Class.newInstanceImpl(Native Method)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
java.lang.Class.newInstance(Class.java:1409)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.app.Instrumentation.newActivity(Instrumentation.java:1061)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.app.ActivityThread.access$1500(ActivityThread.java:132)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.os.Looper.loop(Looper.java:143)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
android.app.ActivityThread.main(ActivityThread.java:4196)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
java.lang.reflect.Method.invokeNative(Native Method)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
java.lang.reflect.Method.invoke(Method.java:507)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
dalvik.system.NativeStart.main(Native Method)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816): Caused by: 
java.lang.UnsatisfiedLinkError: Couldn't load protobuf: findLibrary returned 
null
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
java.lang.Runtime.loadLibrary(Runtime.java:429)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
java.lang.System.loadLibrary(System.java:554)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     at 
com.JCAmbitionAndroid.JCAmbitionAndroid.<clinit>(JCAmbitionAndroid.java:55)
08-25 15:04:37.738: ERROR/AndroidRuntime(7816):     ... 15 more
08-25 15:04:37.808: WARN/ActivityManager(25014):   Force finishing activity 
com.JCAmbitionAndroid/.JCAmbitionAndroid
08-25 15:04:37.868: DEBUG/dalvikvm(4811): GC_EXPLICIT freed 566K, 43% free 
4029K/7047K, external 5122K/6043K, paused 774ms

Original comment by nki...@gmail.com on 25 Aug 2011 at 7:22

GoogleCodeExporter commented 9 years ago
on google group 
http://groups.google.com/group/android-ndk/browse_thread/thread/ba77af4d13dd46cb

Original comment by gaoyu...@gmail.com on 25 May 2012 at 6:39

GoogleCodeExporter commented 9 years ago

Original comment by xiaof...@google.com on 10 Oct 2014 at 1:31