2014-09-29 106 views
0

我在調用以.SO文件編譯的本機方法時遇到此錯誤。 我不爲什麼,因爲一切事情發生似乎是樹立正確的 任何幫助,將不勝感激java.lang.UnsatisfiedLinkError:未找到本地方法:

錯誤:

java.lang.UnsatisfiedLinkError: Native method not found: de.jurihock.voicesmith.dsp.Math.abs:(FF)F 
at de.jurihock.voicesmith.dsp.Math.abs(Native Method) 

CPP文件:pastebin.com/aBHNz642

Math.java

package de.jurihock.voicesmith.dsp; 

public final class Math 
{ 
    static 
     { 
     System.loadLibrary("Voicesmith"); 
     } 

public static final float PI = (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); 

public 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) 
+0

是Math.java中正確的包? – Blackbelt 2014-09-29 16:26:14

+0

是的。它位於de.jurihock.voicesmith.dsp包中; – 2014-09-29 16:43:56

回答

1

你的本地方法abs缺少在其聲明static。您的構建應該是可以趕上的錯誤,Android的工作室做..

嘗試將其更改爲

public static native float abs(float real, float imag);

其他一些建議:

  • Math.h可以與原生標準math.h衝突方(如果你嘗試在Windows上,甚至不會編譯,因爲Windows文件系統是不區分大小寫的......我必須將Math.h更改爲Math2.h)。

  • 即使在Java端,有已經Math類是在java.lang.Math具有相似的功能(例如:java.lang.Math.abs),可以潛在地與java.lang.Math.abs自動完成特別是用於您的代碼段以上,因爲它未命中聲明static(``的java.lang。 Math.abs`是靜態IDE與它匹配的)

+0

我已經刪除了靜態,試圖找出是否是這個問題。我會放回去,嘗試其他兩個建議。謝謝。 – 2014-10-04 15:24:37

相關問題