Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsatisfiedLinkError crash on some devices

I have a published application that is reporting a java.lang.UnsatisfiedLinkError crash on some devices. To be more precise, the app crashes on start up with the following log message:

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load qcc: findLibrary returned null

The actual crashing is in the System.loadLibrary("qcc"); instruction, so the app is not finding the library for sure.

The problem is I haven't been able to reproduce the issue myself. Actually the same apk works perfectly on a lot of different devices and versions.


The app uses two C libraries written and compiled by a third person. They have been compiled using the arm-linux-androideabi-4.6 toolchain, and I am integrating them in my project running nkd-build with the following Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := libqcc
LOCAL_SRC_FILES := qcc/libqcc.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := libqpe
LOCAL_SRC_FILES := qpe/libqpe.so
include $(PREBUILT_SHARED_LIBRARY)

The error is being reported on different devices, but all of them at the moment are one of the following Android versions: 2.2, 2.2.1 or 2.2.2.


I think it could be either an architecture issue or a weird problem during installation.

Does anyone know what the problem could be?


UPDATE:

I realized that I could reproduce the problem in an Android 2.2 emulator. This is extra information that I could gather from the logcat.

11:14:59.962 I/dalvikvm(  287): Unable to dlopen(/data/data/.../lib/libqcc.so): Cannot load library: link_image[1995]: failed to link libqcc.so
11:14:59.962 W/dalvikvm(  287): Exception Ljava/lang/UnsatisfiedLinkError;
like image 862
Xavi Gil Avatar asked Mar 04 '13 17:03

Xavi Gil


1 Answers

In this case the problem was that the library was using some C methods that are not supported on Android 2.2

This link was the way to discover the problem.

Methods such as pthread_rwlock_init are not implemented in the system's C library until Android 2.3 (source).

like image 169
Xavi Gil Avatar answered Oct 07 '22 05:10

Xavi Gil