java.lang.ExceptionInInitializerError

3,068 views
Skip to first unread message

Vaishali

unread,
Aug 2, 2012, 6:54:54 AM8/2/12
to andro...@googlegroups.com
hi,

I ndk-build and compiled a apk . I get this error and have no clue how to fix it. Can someone please give me a pointer in what specific part I should look to fix this . Could this be a problem with the compile . I run a sample hellojni and that runs fine. So could this be a problem with the Android.mk file which defines the source files for the lib. The libs are generated correctly and kept in the lib dir and the apk picks this for the build.

08-01 11:49:22.834: E/AndroidRuntime(2203): FATAL EXCEPTION: main
08-01 11:49:22.834: E/AndroidRuntime(2203): java.lang.ExceptionInInitializerError
08-01 11:49:22.834: E/AndroidRuntime(2203):     at java.lang.Class.newInstanceImpl(Native Method)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at java.lang.Class.newInstance(Class.java:1409)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.os.Looper.loop(Looper.java:130)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at android.app.ActivityThread.main(ActivityThread.java:3835)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at java.lang.reflect.Method.invokeNative(Native Method)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at java.lang.reflect.Method.invoke(Method.java:507)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at dalvik.system.NativeStart.main(Native Method)
08-01 11:49:22.834: E/AndroidRuntime(2203): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]:   115 cannot locate 'FLAC__metadata_object_delete'...
08-01 11:49:22.834: E/AndroidRuntime(2203):     at java.lang.Runtime.loadLibrary(Runtime.java:434)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at java.lang.System.loadLibrary(System.java:554)
08-01 11:49:22.834: E/AndroidRuntime(2203):     at com.sox.player.SoxPlayerActivity.<clinit>(SoxPlayerActivity.java:94)
08-01 11:49:22.834: E/AndroidRuntime(2203):     ... 15 more
08-01 11:49:57.798: E/AndroidRuntime(2228): FATAL EXCEPTION: main

Please give me some hint where the issue is

Thanks for you help . Cheers
Vaishali

David Turner

unread,
Aug 2, 2012, 7:06:45 AM8/2/12
to andro...@googlegroups.com
This means that the library is looking for a symbol named 'FLAC__metadata_object_delete' and cannot find it.
How many shared libraries are there in your apk. If only one, it means you failed to compile/link one or more source files into it.



Vaishali

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

Vaishali

unread,
Aug 2, 2012, 7:13:22 AM8/2/12
to andro...@googlegroups.com
Thank you for the reply . I have many libs that the ndk is compiling as per the build system (android ) . what u mean is this source file with this symbol is not getting compiled correctly in the respective lib. Or this lib with this is symbol is not linking with other libs .

Cheers
Vaishali.

David Turner

unread,
Aug 2, 2012, 7:35:50 AM8/2/12
to andro...@googlegroups.com
On Thu, Aug 2, 2012 at 1:13 PM, Vaishali <vaisha...@gmail.com> wrote:
Thank you for the reply . I have many libs that the ndk is compiling as per the build system (android ) . what u mean is this source file with this symbol is not getting compiled correctly in the respective lib. Or this lib with this is symbol is not linking with other libs .

If you have many libraries, if means that one of them is looking for the symbol in another lib, and could not find it.
Most of the time, this comes from the fact that the library that is supposed to export the symbol doesn't, because a source file was forgotten in the compilation process.

There can be other causes though. Which libraries do you have? Any name that could conflict with the system ones?

Vaishali

unread,
Aug 2, 2012, 7:41:03 AM8/2/12
to andro...@googlegroups.com
ok , then I ll look for this symbol and see which source file this is from. make sure that file is there in the Makefile and maybe do bash debugging to figure whether this file is compiling.I ll check these things and get back.

Vaishali

unread,
Aug 2, 2012, 7:53:05 AM8/2/12
to andro...@googlegroups.com
There are multiple instances of this symbol in various html and 1 tag file .

Vaishali

unread,
Aug 2, 2012, 12:45:53 PM8/2/12
to andro...@googlegroups.com
Hi David,
Thank you for your help so far. This was a Android port of some library. it compiled fine but throws these Runtime errors. As u are pointing out that this is an issue with the libraries not linking correctly. i.e a Linker issue. I was thinking I ll have to check all the Android.mk and Makefiles to ensure that there is no looseend here. I hope I am on the right track. Please guide me with your experience. So I did see that the files with the missing symbol FLAC__metadata_object_delete are compiling. Then probably its a linking error. I ll go through the Android NDK docs to figure something out.
If u have a idea do let me know.

Thanks Again.
Cheers
Vaishali

Vaishali

unread,
Aug 4, 2012, 7:05:13 PM8/4/12
to andro...@googlegroups.com
Hi , The FLAC__metadata_object_delete is present in the  metadata.h in the /include/FLAC . So in the src folder there is a Android.mk file
I added this line to this make file $(LOCAL_PATH)/../include/FLAC  hoping that this would help the libFLAC compilation to export the symbols . But I still get the same error message. Any idea. Why this didnt correct.

Cheers
Vaishali

Vaishali

unread,
Aug 4, 2012, 7:09:47 PM8/4/12
to andro...@googlegroups.com
I mean in the Android.mk I made this change to try to fix this

LOCAL_C_INCLUDES := $(LOCAL_PATH)/libFLAC/include/ \
$(LOCAL_PATH)/../include/ \
$(LOCAL_PATH)/../include/FLAC \
$(LOCAL_PATH)/../../libogg/include/

Cheers
Vaishali

Vaishali

unread,
Aug 4, 2012, 8:28:57 PM8/4/12
to andro...@googlegroups.com
Finally this worked. OK ..

I changed the Android.mk file in the src for flac lib .
/home/vaishali/SoxPlayer/jni/sox/flac/src

include $(BUILD_SHARED_LIBRARY) was changed to
include $(BUILD_STATIC_LIBRARY)

Cheers
Vaishali.
Reply all
Reply to author
Forward
0 new messages