UnsatisfiedLinkError in pjsip library - android

I build Pjsip library and use its sample in android studio .
question
When I run that i got this error.How could I solve it ? thanks in advance.
exception
jsip.pjsua2.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.pjsip.pjsua2.app, PID: 4360
java.lang.UnsatisfiedLinkError: No implementation found for void org.pjsip.pjsua2.pjsua2JNI.swig_module_init() (tried Java_org_pjsip_pjsua2_pjsua2JNI_swig_1module_1init and Java_org_pjsip_pjsua2_pjsua2JNI_swig_1module_1init__)
at org.pjsip.pjsua2.pjsua2JNI.swig_module_init(Native Method)
at org.pjsip.pjsua2.pjsua2JNI.(pjsua2JNI.java:2351)
at org.pjsip.pjsua2.Endpoint.(Endpoint.java:68)
at org.pjsip.pjsua2.app.MyApp.(MyApp.java:296)
at org.pjsip.pjsua2.app.MainActivity.onCreate(MainActivity.java:92)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)

It may happen for several reasons. First, check if you attached the native library correctly. For that create a folder named "jniLibs" into the projects
app/src/main/jniLibs
then put your armeabi architecture library like
armeabi/libpjsua2.so
for other architecture like armeabi-v7a use
armeabi-v7a/libpjsua2.so
like this.
there are other reasons may happen. If you build pjsip library for armeabi architecture only and running your application in an x86 architecture device then this error may occur. So check it also if you have built it for that application.

Please take a look at this thread: building pjsua2 dll
the important thing to know here is that the error you show in your question is caused by the fact that the pjsua2.dll (a c++ dll) is not in your output directory.

Related

java.lang.UnsatisfiedLinkError- While loading customized .so files

OpenCV increasing size of apk So I customized OpenCV and reduced its size by this. All scripts ran fine and I got new libopencv_java4.so with reduced size. Now I updated these files into my project which already working fine (Only has issue with size) But now I am getting error like:`
java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "C:/Users/ubuntu/Desktop/Development/Android/MyProject/opencv/native/libs/armeabi-v7a/libopencv_java4.so" needed by "libnative-lib.so"; caused by library "C:/Users/ubuntu/Desktop/Development/Android/MyProject/opencv/native/libs/armeabi-v7a/libopencv_java4.so" not found
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:989)
at com.abc.android.count_ai.BaseActivity.<clinit>(BaseActivity.java:11)
at com.abc.android.sdk.MainActivity.<init>(MainActivity.java:46)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1650)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2640)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
`
I just updated newly generated customized opencv shared libs in project. Before that project was working. Am I missing something? or I have to do something with newly generated opencv .so files to make these working.
As I faced this issue I again switch to original files and ran the project. Its working. Issue is with only new files. I ran `
arm-linux-androideabi-strip --strip-unneeded libopencv_tiny.so
`
This command at last as given in link. Is this creating problem?

Pjsip java.lang.UnsatisfiedLinkError: dlopen failed: for armeabi-v7a

I am trying to build libpjsua2.so using armeabi-v7a architecture type.
Here are the steps I followed:
https://trac.pjsip.org/repos/wiki/Getting-Started/Android
I just changed TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags and rest everything kept as it is.
It worked well with arm64-v8a and I am able to run project on Google Pixel.
When I build armeabi-v7a, I didn't receive any errors but when I run the project on Nexus 5, it gives me the following error:
08-09 16:52:01.625 19296-19296/com.pjdroid.sample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pjdroid.sample, PID: 19296
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memclr8" referenced by "/data/app/com.pjdroid.sample-1/lib/arm/libpjsua2.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:1076)
at com.pjdroid.sample.MyApp.(MyApp.java:278)
at com.pjdroid.sample.MainActivity.onCreate(MainActivity.java:114)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I tried several times make clean and remove everything but every time I received this error.
I think there's some issue in creating this file for armeabi-v7a.
Can you suggest me if I am doing anything wrong in this?
Read the documentation. This is what the PJSIP getting started guide has to say (almost at the bottom)
UnsatisfiedLinkError exception with "cannot locate 'rand'" message.
As described ​here, this happens if you've built your native components with the android-21 target, but are trying to run it on a device with an older Android version, so re-run configure with APP_PLATFORM set to lower platform version, e.g:
APP_PLATFORM=android-19 ./configure-android

Android app loading ARM shared library on x86 device fails

I have a really simple android app. I want to load a shared library called 'libcamera.so' and then call methods via JNI.
I do not own this library and I do not have access to the source code. It was originally compiled for ARM.
An x86 version is not available.
The project can detect the library and correctly shows it in the jniLibs folder.
Within my main activity I am trying to load the 3rd party library like so:
static {
System.loadLibrary("camera");
}
When this line executes, logcat shows the following:
02-06 14:11:38.517 4455-4455/uk.co.test.myApp E/art: dlopen("/data/app/uk.co.test.myApp-2/lib/x86/libcamera.so", RTLD_LAZY) failed: dlopen failed: "/data/app/uk.co.test.myApp-2/lib/x86/libcamera.so" has unexpected e_machine: 40
02-06 14:11:38.519 4455-4455/uk.co.test.myApp E/AndroidRuntime: FATAL EXCEPTION: main
Process: uk.co.test.myApp, PID: 4455
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/uk.co.test.myApp-2/lib/x86/libcamera.so" has unexpected e_machine: 40
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:988)
at uk.co.test.myApp.MainActivity.<clinit>(MainActivity.java:17)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1603)
at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Other 3rd party apps which use this library can run on my x86 device (Epson BT350) so I feel like this should be possible.
I have become aware of something called 'Houdini' which allows ARM apps to run on x86 - I have checked and my device has this library so im confused why its not doing its job. But its also quite likely I dont really understand how Houdini works!
I have tried running on an x86 emulator - same error.
Any ideas would be greatly appreciated.
I solved the problem by forcing my app to only build an armeabi version. I did this by using an abifilter within gradle. I added the following to my defaultConfig
ndk {
abiFilters "armeabi"
}
This will then run on my x86 device because Houdini will kick in and do the translation. Its not ideal because this translation affects performance - but its a start and gets me to the next stage.

Visual Studio Xamarin android app crashes

I'm trying to run an android xamarin app in Visual Studio 2013, it deploys normally, but crashes after start.
Here is the log:
java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_22 or Xamarin.Android.Pla
at android.app.ActivityThread.installProvider(ActivityThread.java:5002)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_22 or Xamarin.Android.Platform!
at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38)
at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
... 11 more
Caused by: android.content.pm.PackageManager$NameNotFoundException: Xamarin.Android.Platform
at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:281)
at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:32)
The same thing on emulator with any platform and device.
Thank you in advance.
With the last Xamarin Update i run into this problem as well.
Try disabling "Use shared runtime" in your Android Build options. It seems with the current Version a developent build is not able to call into the shared mono runtime.
--> https://forums.xamarin.com/discussion/52439/unable-to-get-provider-mono-monoruntimeprovider
What helped some others:
Some suggested to just change "Target Version" (and "Compile Version" for VS) and Rebuild. The important part was to have changes in the Project File and not what exactly you changed "Target Version" from and to.
--> https://stackoverflow.com/a/32607524/383658

java.lang.UnsatisfiedLinkError after updating to Android 5.0

I'm developing an Android app which uses a native library called liballjoyn_java.so (available here in the Android Core SDK). I'm using Android Studio as IDE and Maven as build/dependency system (not Gradle). With Android KitKat everything worked like a charm and this is how I added the library to my project:
1) Added the library to my local Maven repo
mvn install:install-file -Dfile=./alljoyn/liballjoyn_java.so -DgroupId=org.alljoyn -DartifactId=liballjoyn_java -Dversion=14.06.00 -Dscope=runtime -Dpackaging=so
2) Defined a dependency in the POM file:
<dependency>
<groupId>org.alljoyn</groupId>
<artifactId>liballjoyn_java</artifactId>
<scope>runtime</scope>
<type>so</type>
<version>14.06.00</version>
</dependency>
3) Called it statically from my code:
static {
try {
System.loadLibrary("alljoyn_java");
Log.d("AllJoynManager", "static - Loaded AllJoyn native library");
} catch (Exception exception) {
Log.d("AllJoynManager", "static - Error loading AllJoyn native library");
exception.printStackTrace();
}
}
This was working perfectly under KitKat in my Nexus 4 phone but now I installed the official Android 5.0 OTA update and I get the following error on runtime:
11-28 17:57:39.988 30068-30068/com.avispalabs.kiihome E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.avispalabs.kiihome, PID: 30068
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.avispalabs.kiihome-2/base.apk"],nativeLibraryDirectories=[/data/app/com.avispalabs.kiihome-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "liballjoyn_java.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at com.avispalabs.kiihome.helpers.network.alljoyn.AlljoynManager.<clinit>(AlljoynManager.java:38)
at com.avispalabs.kiihome.ui.activities.MainActivity.<init>(MainActivity.java:38)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1572)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
11-28 17:57:55.432 30068-30068/com.avispalabs.kiihome I/Process﹕ Sending signal. PID: 30068 SIG: 9
I suspect the .so library might have been compiled in way which is somehow incompatible with the new Android 5.0 ART (?). The message that says it can't find the library is probably misleading (the exception is also seen when a library fails to load) but I'm not sure (another possibility is the .so is not correctly extracted or placed).
The library comes precompiled and is advertised to be compatible with JellyBean. I thought previous dynamic libraries would be compatible with new versions of Android, otherwise a lot of apps would break. If I install the same APK in a Nexus 4 with KitKat it just works.
Any advice is highly appreciated.
UPDATE: I have tested my project in a KitKat based device and switched the runtime to ART rather than Dalvik, and the project works fine. This problem seems to be tied to Android 5 rather than ART itself.
Answering my own question here. You can solve it by compiling liballjoyn_java as PIE as explained here:
https://jira.allseenalliance.org/browse/ASACORE-1208
This is a workaround until the AllJoyn guys publish a new Android build. Keep an eye here to get the updated release:
https://build.allseenalliance.org/ci/view/Core%20RB14.12%20SDK/job/branch-android-sdk/

Categories

Resources