Cannot load library: reloc_library[1285]: cannot locate 'rand' - android

I'm trying to use PJSIP library for my Android application.
I built pjsua sample application according to this manual:
https://trac.pjsip.org/repos/wiki/Getting-Started/Android
But when sample application is launching, exception triggers:
12-06 15:03:58.043: D/dalvikvm(628): Trying to load lib /data/data/org.pjsip.pjsua2.app/lib/libpjsua2.so 0x4129d980
12-06 15:03:58.064: W/dalvikvm(628): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/pjsip/pjsua2/app/MyApp;
12-06 15:03:58.064: D/AndroidRuntime(628): Shutting down VM
12-06 15:03:58.064: W/dalvikvm(628): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
12-06 15:03:58.083: E/AndroidRuntime(628): FATAL EXCEPTION: main
12-06 15:03:58.083: E/AndroidRuntime(628): java.lang.ExceptionInInitializerError
12-06 15:03:58.083: E/AndroidRuntime(628): at org.pjsip.pjsua2.app.MainActivity.onCreate(MainActivity.java:85)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.Activity.performCreate(Activity.java:4465)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.ActivityThread.access$600(ActivityThread.java:123)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.os.Handler.dispatchMessage(Handler.java:99)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.os.Looper.loop(Looper.java:137)
12-06 15:03:58.083: E/AndroidRuntime(628): at android.app.ActivityThread.main(ActivityThread.java:4424)
12-06 15:03:58.083: E/AndroidRuntime(628): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 15:03:58.083: E/AndroidRuntime(628): at java.lang.reflect.Method.invoke(Method.java:511)
12-06 15:03:58.083: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-06 15:03:58.083: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-06 15:03:58.083: E/AndroidRuntime(628): at dalvik.system.NativeStart.main(Native Method)
12-06 15:03:58.083: E/AndroidRuntime(628): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 37 cannot locate 'rand'...
12-06 15:03:58.083: E/AndroidRuntime(628): at java.lang.Runtime.loadLibrary(Runtime.java:370)
12-06 15:03:58.083: E/AndroidRuntime(628): at java.lang.System.loadLibrary(System.java:535)
12-06 15:03:58.083: E/AndroidRuntime(628): at org.pjsip.pjsua2.app.MyApp.<clinit>(MyApp.java:235)
It seems like appl cannot load libpjsua2.so library. I have never used the NDK before, so i don't have any ideas about this issue, please help me...

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. Unless you take very special care, you can't run binaries built with the android-21 target on older devices. For basic C functions, it shouldn't matter which target version between android-3 and android-20 you use, it should work on all of them, but if you use android-21 it only works on that version and newer.
See https://stackoverflow.com/a/27093163/3115956 for more details on this issue.

mstorsjo answers my question. But i want write one comment:
I had correct properties files, but during pjsip building I found following logs:
sip#ubuntu:~/pjsip/trunk$ ./configure-android
configure-android: APP_PLATFORM not specified, using android-21
configure-android: TARGET_ABI not specified, using armeabi
So if you want compile the project on some specific platform version, you have to set APP_PLATFORM parameter for configure-android script.
TARGET_ABI=armeabi-v7a APP_PLATFORM=android-8 ./configure-android --use-ndk-cflags

I have encountered this when using HUAWEI phone with opus and pngquant jni library for android.
Finally the solution is that I add rand,srand and atof function implementions in my source file. Then the problem gone.
Solution from https://github.com/cocos2d/cocos2d-x/issues/15234
Try it!
static u_long myNextRandom = 1;
double atof(const char *nptr)
{
return (strtod(nptr, NULL));
}
int rand(void)
{
return (int)((myNextRandom = (1103515245 * myNextRandom) + 12345) % ((u_long)RAND_MAX + 1));
}
void srand(u_int seed)
{
myNextRandom = seed;
}

Related

Android Google Analytics compile error "Could not find class"

I have called:
compile 'com.google.android.gms:play-services-analytics:7.5.0'
When I run project I get an error:
Log cat :
06-26 15:39:17.563 2415-2415/com.demo E/dalvikvm﹕ Could not find class 'com.demo.utils.logger.ChainedLogNode', referenced from
method com.demo.utils.logger.Logger.initialize.
When I remove compile 'com.google.android.gms:play-services-analytics:7.5.0', it runs ok.
Stop app :
6-26 15:39:17.579 2415-2415/com.demo.app E/AndroidRuntime﹕ FATAL
EXCEPTION: main
java.lang.NoClassDefFoundError: com.demo.utils.logger.ChainedLogNode
at com.demo.utils.logger.Logger.initialize(Logger.java:150)
at com.demo.utils.CommonUtil.setupLoggers(CommonUtil.java:3215)
at com.demo.DemoApplication.onCreate(DemoApplication.java:103)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Facebook apk for emulator constantly crashing

Facebook apk delivered with sdk 4.1.0 doesn't not work in emulators where it supposed to work(sdk emulator and genymotion)
It always crashes with the same exception
05-08 08:42:42.022 3279-3279/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: could find DSO to load: libbreakpad.so
at com.facebook.soloader.SoLoader.a(SoLoader.java:179)
at com.facebook.soloader.SoLoader.a(SoLoader.java:144)
at com.facebook.breakpad.BreakpadManager.a(BreakpadManager.java:55)
at com.facebook.breakpad.BreakpadManager.b(BreakpadManager.java:78)
at com.facebook.breakpad.BreakpadManager.a(BreakpadManager.java:82)
at com.facebook.katana.app.FacebookApplication.b(FacebookApplication.java:169)
at com.facebook.base.app.DelegatingApplication.attachBaseContext(DelegatingApplication.java:62)
at android.app.Application.attach(Application.java:146)
at android.app.Instrumentation.newApplication(Instrumentation.java:983)
at android.app.Instrumentation.newApplication(Instrumentation.java:967)
at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4124)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Any solution?
Change your avd image from x86 to Arm.
It should work with you now.

Cordova hello world app crashing

I am new in Android Development. I am working on cordova platform
I have created a sample hello world app and getting this error when i am trying to open it in genymotion. ALthough the app compile succesfully but when i run it in genymotion it just shows the prompt with text "Unfortunately "APP" has stopped."
The Error log shows.
01-12 08:16:04.867 2073-2073/com.technoserves.crudnew D/dalvikvm﹕ Late-enabling CheckJNI
01-12 08:16:06.107 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ Unable to resolve superclass of Lcom/technoserves/crudnew/CordovaApp; (14)
01-12 08:16:06.119 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ Link of class 'Lcom/technoserves/crudnew/CordovaApp;' failed
01-12 08:16:06.135 2073-2073/com.technoserves.crudnew D/AndroidRuntime﹕ Shutting down VM
01-12 08:16:06.135 2073-2073/com.technoserves.crudnew W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa6142908)
01-12 08:16:06.155 2073-2073/com.technoserves.crudnew E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.technoserves.crudnew/com.technoserves.crudnew.CordovaApp}: java.lang.ClassNotFoundException: Didn't find class "com.technoserves.crudnew.CordovaApp" on path: /data/app/com.technoserves.crudnew-1.apk
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.technoserves.crudnew.CordovaApp" on path: /data/app/com.technoserves.crudnew-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)
01-12 08:16:22.399 2073-2073/com.technoserves.crudnew I/Process﹕ Sending signal. PID: 2073 SIG: 9
I have updated my cordova to resolve but still same error however a few days ago it was working fine and i have build some apps.
First download Cordova jar file from following link:
http://www.java2s.com/Code/JarDownload/cordova/cordova-1.8.1.jar.zip
after that extract the folder and put cordova-1.8.1 inside your libs folder of project in eclipse
And right click on your project--> properties and Select Android from left pane and scroll to bottom remove the cordova library if added.
then clean and build your project.

Vuforia jPCT integration and build jni

I getting following error while running imagetarge vuforia jPCT project
W/dalvikvm(3469): threadid=1: thread exiting with uncaught exception (group=0xa4c4e648)
E/AndroidRuntime(3469): FATAL EXCEPTION: main
E/AndroidRuntime(3469): java.lang.UnsatisfiedLinkError: Native method not found: com.qualcomm.ar.pl.CameraPreview.newFrameAvailable:(IIII[B)V
E/AndroidRuntime(3469): at com.qualcomm.ar.pl.CameraPreview.newFrameAvailable(Native Method)
E/AndroidRuntime(3469): at com.qualcomm.ar.pl.CameraPreview.onPreviewFrame(CameraPreview.java:805)
E/AndroidRuntime(3469): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:791)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(3469): at android.app.ActivityThread.main(ActivityThread.java:5103)
E/AndroidRuntime(3469): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(3469): at java.lang.reflect.Method.invoke(Method.java:525)
E/AndroidRuntime(3469): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
E/AndroidRuntime(3469): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(3469): at dalvik.system.NativeStart.main(Native Method)
I read all vuforia blog and google search but not able to solve problem
Please help me...
Used latest vaforia.jar to solve problem
Download latest sdk from https://developer.vuforia.com/resources/sdk/android

Error after importing Android project [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I moved an Eclipse-based Android project from another machine to the machine that I am working with. I imported the project using Android Project from Existing Source. Everything is working well when I code but when I deploy it using emulators and phones, it's producing weird exceptions. What might be the problem?
I have attached the exceptions produced with the questions for information.
12-06 08:15:20.957: E/AndroidRuntime(767): FATAL EXCEPTION: main
12-06 08:15:20.957: E/AndroidRuntime(767): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.innolabmm.discoverlioncity/com.innolabmm.discoverlioncity.FeedActivity}: java.lang.ClassNotFoundException: Didn't find class "com.innolabmm.discoverlioncity.FeedActivity" on path: /data/app/com.innolabmm.discoverlioncity-1.apk
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.os.Handler.dispatchMessage(Handler.java:99)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.os.Looper.loop(Looper.java:137)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.ActivityThread.main(ActivityThread.java:5041)
12-06 08:15:20.957: E/AndroidRuntime(767): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 08:15:20.957: E/AndroidRuntime(767): at java.lang.reflect.Method.invoke(Method.java:511)
12-06 08:15:20.957: E/AndroidRuntime(767): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-06 08:15:20.957: E/AndroidRuntime(767): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-06 08:15:20.957: E/AndroidRuntime(767): at dalvik.system.NativeStart.main(Native Method)
12-06 08:15:20.957: E/AndroidRuntime(767): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.innolabmm.discoverlioncity.FeedActivity" on path: /data/app/com.innolabmm.discoverlioncity-1.apk
12-06 08:15:20.957: E/AndroidRuntime(767): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
12-06 08:15:20.957: E/AndroidRuntime(767): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-06 08:15:20.957: E/AndroidRuntime(767): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
12-06 08:15:20.957: E/AndroidRuntime(767): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
12-06 08:15:20.957: E/AndroidRuntime(767): ... 11 more
Try this:
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it.Mark all checkboxes and Click on Apply and clean the project.
Hope this helps.

Categories

Resources