can not load m3u8library :java.lang.unstisfiedllinke

I keep getting this error when making calls to my native methods compiled in an .SO file.
i dont why its happening since everything seems to be set up right
any help would be appreciated
java.lang.UnsatisfiedLinkError: Native method not found: de.jurihock.voicesmith.dsp.Math.abs:(FF)F
at de.jurihock.voicesmith.dsp.Math.abs(Native Method)
package de.jurihock.voicesmith.
public final class Math
System.loadLibrary("Voicesmith");
public static final float
= (float) java.lang.Math.PI;
public static int round(float value)
return java.lang.Math.round(value);
public static native float pow(float base, float exponent);
public static native float log10(float value);
public static native float min(float a, float b);
public static native float max(float a, float b);
public static native float floor(float value);
public static native float ceil(float value);
public static native float sin(float angle);
public static native float cos(float angle);
public static native float sqrt(float value);
public static native float atan2(float y, float x);
native float abs(float real, float imag);
public static native float arg(float real, float imag);
public static native float real(float abs, float arg);
public static native float imag(float abs, float arg);
public static native float random(float min, float max);
public static native float princarg(float phase);
public static native short mean(short[] buffer, int offset, int length);
public static native float rms(short[] buffer, int offset, int length);
public static native float rms(short[] buffer, int offset, int length, short mean);
public static native float rms2dbfs(float value, float min, float max);
android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Name of the library without prefix "lib" and file extension
LOCAL_MODULE := Voicesmith
# Optimization flags (see KissFFT makefile)
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -Wall -O3 -ffast-math -funroll-loops -fomit-frame-pointer
# LogCat support
# LOCAL_LDLIBS := -llog
# Debugging flag
# LOCAL_CFLAGS += -g
# Include all .c/.cpp files to build
LOCAL_SRC_FILES := $(shell cd $(LOCAL_PATH); \
find . -type f -name '*.c'; \
find . -type f -name '*.cpp')
include $(BUILD_SHARED_LIBRARY)
your native method abs is missing static in its declaration. Your build should have caught the error, Android Studio does..
Try changing it to
public static native float abs(float real, float imag);
Some other suggestions:
name Math.h can conflict with standard math.h on native side (wont even compile if you try on windows, as windows file system is case insensitive ... i had to change your Math.h to Math2.h).
Even on java side, there is already Math class at java.lang.Math with similar functions (eg: java.lang.Math.abs), can potentially autocomplete with java.lang.Math.abs particularly for your code snippet above as it misses static in declaration (``java.lang.Math.abs` is static IDE matches to it)
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledSotirios-Efstathios (Stathis) Maneas is a postgraduate student at the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. His main interests include distributed systems, web crawling, model checking, operating systems, programming languages and web applications.
java.lang.unsatisfiedlinkerror – How to handle Unsatisfied Link Error Posted by:
In this tutorial we will discuss about Java’s
and how to deal with it. The
is a sub-class of the
class and denotes that the Java Virtual Machine (JVM) cannot find an appropriate native-language definition of a method declared as native. This error exists since the first release of Java (1.0) and is thrown only at runtime.The
is thrown when an application attempts to load a native library like .so in Linux, .dll on Windows or .dylib in Mac and that library does not exist. Specifically, in order to find the required native library, the JVM looks in both the PATH environment variable and the java.library.path system property.A sample example that throws the aforementioned error is presented below:UnsatisfiedLinkErrorExample.java:
public class UnsatisfiedLinkErrorExample {
// Define a method that is defined externally.
native void CFunction();
// Load an external library, called "clibrary".
System.loadLibrary("clibrary");
public static void main(String argv[]) {
UnsatisfiedLinkErrorExample example = new UnsatisfiedLinkErrorExample();
example.CFunction ();
In this example, we define a native method called CFunction, which exists in the library under the name clibrary. In our main function we try to call that native method, but the library is not found and the following exception is thrown:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no clibrary in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at main.java.Example.&clinit&(Example.java:10)
In order to resolve this issue, we must add the clibrary native library in the system path of our application.How to deal with the UnsatisfiedLinkErrorFirst of all we must verify that the parameter passed in the System.loadLibrary method is correct and that the library actually exists. Notice that the extension of the library is not required. Thus, if your library is named SampleLibrary.dll, you must pass the SampleLibrary value as a parameter.Moreover, in case the library is already loaded by your application and the application tries to load it again, the
will be thrown by the JVM. Also, you must verify that the native library is present either in the java.library.path or in the PATH environment library of your application. If the library still cannot be found, try to provide an absolute path to the System.loadLibrary method.In order to execute your application, use the -Djava.library.path argument, to explicitly specify the native library. For example, using the terminal (Linux or Mac) or the command prompt (Windows), execute your application by issuing the following command:
java -Djava.library.path= "&path_of_your_application&" –jar &ApplicationJAR.jar&
Final comments on the ErrorIt is very important to discuss and notice that:Using native methods make your Java application code platform dependent.The System.loadLibrary method is equivalent as executing the Runtime.getRuntime().loadLibrary method.The System.loadLibrary method shall be used in a static initializer block, in order to be loaded only once, when the JVM loads the class for the first time.& This was a tutorial about Java’s .
Do you want to know how to develop your skillset to become a Java Rockstar?Subscribe to our newsletter to start Rocking right now!To get you started we give you our best selling eBooks for FREE!1. JPA Mini Book2. JVM Troubleshooting Guide3. JUnit Tutorial for Unit Testing4. Java Annotations Tutorial5. Java Interview Questions6. Spring Interview Questions7. Android UI Designand many more ....& Email address:
Examples Java Code Geeks and all content copyright (C) ,
Want to take your Java Skills to the next level?Grab our programming books for FREE!Save time by leveraging our field-tested solutions to common problems.The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.Each book comes as a standalone guide (with source code provided), so that you use it as reference. Last Step ...Where should we send the free eBooks? Good Work!To download the books, please verify your email address by following the instructions found on the email we just sent you.Troubleshooting: java.lang.UnsatisfiedLinkError
Troubleshooting: java.lang.UnsatisfiedLinkError
Applies to: dtSearch Engine 6.20 and later
This error occurs running an application that uses the dtSearch Engine's Java API:
java.lang.UnsatisfiedLinkError: no dtsjava in java.library.path
Resolution: Windows (32-bit)
Under Windows, the Java interface to the dtSearch Engine is implemented with three files:
dtSearchEngine.jar, which has the Java classes
dtsjava.dll, a JNI wrapper around the dtSearch Engine's C++ interface
dten600.dll, the dtSearch Engine, which performs the indexing and searching functions
dtSearchEngine.jar must be in one of the folders that is listed in the CLASSPATH environment variable.   Adding the dtSearch Engine examples/java/classes folder to the CLASSPATH, or copying its contents to a folder on the CLASSPATH, will make these classes available in Java.
dtsjava.dll and dten600.dll must be in one of the folders that is listed in the PATH environment variable.   For instructions on changing the PATH environment variable, see "How to change the system PATH", below.  Note that Windows has two PATH variables: one "System" path which applies to all users, and one for the current user.   Changes to the current user path may not be visible to some programs, such as services or programs that run in the context of a web server.   Therefore, any changes should be made to the System PATH.  Usually a reboot is needed for changes to the System PATH to be recognized.
Resolution: Windows (64-bit)
Under Windows, the Java interface to the dtSearch Engine is implemented with three files:
dtSearchEngine.jar, which has the Java classes
dtsjava.dll, a JNI wrapper around the dtSearch Engine's C++ interface (use the one from the dtSearch bin64 folder)
dtengine64.dll, the dtSearch Engine, which performs the indexing and searching functions
dtSearchEngine.jar must be in one of the folders that is listed in the CLASSPATH environment variable.   Adding the dtSearch Engine examples/java/classes folder to the CLASSPATH, or copying its contents to a folder on the CLASSPATH, will make these classes available in Java.
dtsjava.dll and dtengine64.dll must be in one of the folders that is listed in the PATH environment variable.   For instructions on changing the PATH environment variable, see "How to change the system PATH", below.  Note that Windows has two PATH variables: one "System" path which applies to all users, and one for the current user.   Changes to the current user path may not be visible to some programs, such as services or programs that run in the context of a web server.   Therefore, any changes should be made to the System PATH.  Usually a reboot is needed for changes to the System PATH to be recognized.
Both the 32-bit and the 64-bit dtsjava.dll have the same name. The version you use must match the Java version you are using, so under 64-bit Java you should use the 64-bit version of dtsjava.dll. To ensure that the correct version is used with the Java version you have, set the system PATH so the correct dtSearch folder (bin64 or bin) comes first. For example, to use the 64-bit version, set up your system path with C:\Program Files\dtSearch Developer\bin64 ahead of C:\Program Files\dtSearch Developer\bin. 
Resolution: Linux
Under Linux, the Java interface to the dtSearch Engine is implemented with two files:
dtSearchEngine.jar, which has the Java classes
libdtsjava.so, which includes both the dtSearch Engine and a JNI wrapper around the dtSearch Engine's C++ interface
dtSearchEngine.jar just be in one of the folders that is listed in the CLASSPATH environment variable.   
libdtsjava.so must be in a folder that is listed in the LD_LIBRARY_PATH environment variable.  You can also copy the dtSearch .so files to your /usr/local/lib folder, or use ldconfig to make them accessible on your system.
The 32-bit and the 64-bit libdtsjava.so have the same name. The version you use must match the Java version you are using, so under 64-bit Java you should use the 64-bit version of libdtsjava.so. To ensure that the correct version is used with the Java version you have, set the LD_LIBRARY_PATH so the correct dtSearch folder (lib64 or lib) comes first.
How to change the system PATH in Windows
The PATH is a list of folder names that Windows uses to locate executables.   The following steps will add the dtSearch program folder to the system PATH.
(1) Click Start & Settings & Control Panel
(2) Click System
(3) Click the Advanced tab.
(4) Click the Environment Variables button
(5) Under System variables, locate the "Path" variable and click on it
(6) Click the Edit button
(7) Add this to the end of the current value (assuming you installed dtSearch to the default location):
;c:\Program Files\dtSearch Developer\bin
The semicolon is needed to separate the dtSearch directory name from the last item listed in the existing PATH.  
A reboot may be necessary for some programs to recognize the change to the PATH.}

我要回帖

更多关于 can not load file 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信