Re: [discuss-webrtc] libjingle android example - problem with libjingle_peerconnection_so.so file

2,078 views
Skip to first unread message

Ami Fischman

unread,
Mar 8, 2013, 11:36:43 AM3/8/13
to discuss...@googlegroups.com
On Thu, Mar 7, 2013 at 1:49 PM, Harsányi Gábor <harsan...@gmail.com> wrote:
Hi there,

Everything is okay, build process is succeed, libjingle_peerconnection_so.so is generated but for this line: 
<path/to/android-ndk-r8d>/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip -o libs/armeabi-v7a/libjingle_peerconnection_so.so  ../../../out/Debug/libjingle_peerconnection_so.so
I got the following error message. "File format not recognized"


What kind of file is out/Debug/libjingle_peerconnection_so.so?  I.e. from your build root what does
file out/Debug/libjingle_peerconnection_so.so
say?  My guess is that it is an x86 binary (instead of being an ARM binary) and that's why the ARM-targeting strip is failing.

Do you have a $GYP_GENERATOR_FLAGS variable telling gyp to emit output to an output_dir other than "out"?  (i.e. maybe you're trying to use an earlier, non-android build artifact)
Perhaps you have an android and a linux build conflicting for the same dir?

For my own work building this stuff I use out/ for x86 output artifacts and out_a ('a' for "android") with:
export GYP_GENERATOR_FLAGS=' default_target=All output_dir=out_a'
(it's that last bit that matters).  You might want to do the same in your workflow.

FTR, an x64 "file" output looks like this:
out/Debug/libjingle_peerconnection_so.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0xb6490d0eeba8c34d657a951c016643222e0238ad, not stripped
whereas ARM output looks like this:
out_a/Release/libjingle_peerconnection_so.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

You need the file that's fed to to arm-linux-androideabi-strip to match the second one of these for things to work.
 
both of the build processes use hard coded java home like: /usr/local/buildtools/java/jdk7-64 when the process try to find jni.h ($JAVA_HOME/include and $JAVA_HOME/include/linux) Or it's not hard coded just I'm using it in wrong way :)

No, you're right, and it's my fault.  Bug 1486 tracks fixing this.

I also tried just copy the libjingle_peerconnection_so.so into libs/armeabi-v7a and in this case the apk was generated and was installed successfully on emulator but i got the following exception:

03-07 12:21:28.912: E/AndroidRuntime(1242): FATAL EXCEPTION: main
03-07 12:21:28.912: E/AndroidRuntime(1242): java.lang.NoClassDefFoundError: org.appspot.apprtc.AppRTCDemoActivity$PCObserver

03-07 12:21:28.912: E/AndroidRuntime(1242): at org.appspot.apprtc.AppRTCDemoActivity.<init>(AppRTCDemoActivity.java:68)

That's weird - it's failing to find an inner class in a class it's already found!  
Perhaps take a look at the apk's dex's contents to see what classes are actually pushed to the device.

Cheers,
-a

Harsányi Gábor

unread,
Mar 8, 2013, 2:20:24 PM3/8/13
to discuss...@googlegroups.com
Thank you very much, you helped a lot! You are right, my "so" file was an x86 binary.

Harsányi Gábor

unread,
Mar 18, 2013, 9:51:52 AM3/18/13
to discuss...@googlegroups.com
Hi,

maybe you should check these topics:
  • change ninja build to create ARM binary
  • AppRTC Demo on Android
Those contain almost step by step instructions as well.


On Monday, March 18, 2013 11:17:23 AM UTC+2, Michael Poschacher wrote:
Hello, 

I tried do build the shared object, the output is a 64-bit so file (same as above), how can I build one for arm?

kind regards,
Micahel

Sebastian Kummer

unread,
Mar 18, 2013, 11:39:12 AM3/18/13
to discuss...@googlegroups.com
Hi Harsányi, do you got the demo running? Mine still keeps crashing.. (although the SO is ARM..)

Harsányi Gábor

unread,
Mar 19, 2013, 8:20:48 AM3/19/13
to discuss...@googlegroups.com
Hi,

not yet :)
'cause I didn't have time to work on it nowadays. But as I can see in this topic, it's almost done -> AppRTC android client crashes - NoClassDefFoundError: org.appspot.apprtc.AppRTCDemoActivity$PCObserv

maybe you can write me what is the error message you found?

Sebastian Kummer

unread,
Mar 19, 2013, 10:34:05 AM3/19/13
to discuss...@googlegroups.com
Hi Harsányi,

I think the NoClassDefFoundError occurs because the jni java-wrapper classes are not found (PCObserver implements org.webrtc.PeerConnection.Observer). Did you build the libjingle_peerconnection.jar using ninja? If no, try these steps:

 1. gclient config http://libjingle.googlecode.com/svn/trunk
 2. sync --force
 3. set 'libjingle_java' to 1 in trunk/talk/build/common.gypi line 38
 4. set correct JDK path in trunk/talk/libjingle.gyp line 61
 5. export GYP_GENERATORS='ninja'
 6. source ./build/android/envsetup.sh
 7. gclient runhooks
 8. ninja -C out/Debug libjingle_peerconnection_test_jar
 9. cd talk/examples/android
10. cp ../../../out/Debug/libjingle_peerconnection.jar libs/
11. <path/to/android-ndk-r8d>/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip -o libs/armeabi-v7a/libjingle_peerconnection_so.so  ../../../out/Debug/libjingle_peerconnection_so.so
12. ant debug
13. adb install -r bin/AppRTCDemo-debug.apk
14. adb shell am force-stop org.appspot.apprtc

Otherwise, you can open the android project in eclipse and link the java sourcefiles manually from talk/app/webrtc/java/src

My current problem is a segmentation fault in the native code. You can stare at http://code.google.com/p/webrtc/issues/detail?id=1518

Harsányi Gábor

unread,
Mar 23, 2013, 8:17:15 PM3/23/13
to discuss...@googlegroups.com
Hi,

thank you so much, I'll try out on Monday. I'm sorry for the delayed answer just I was on holiday.
Reply all
Reply to author
Forward
0 new messages