我正在嘗試使用JTransforms庫來計算Android應用程序(使用最新的Android Studio)中的數學函數(DoubleFFT_1D)。我正在使用JTransforms website提供的.jar文件,並將其導入到項目中。我已經嘗試了JTransforms修訂版2.4和3.1。代碼編譯沒有錯誤,但是當我得到實際的方法調用,我得到了以下錯誤消息:Android:java.lang.NoClassDefFoundError
09-07 17:30:11.369 E/JavaBinder: *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/jtransforms/fft/DoubleFFT_1D;
at com.algoint.libzante.AutoCorrelation.compute(AutoCorrelation.java:66)
at com.algoint.libzante.EstimateACF.estimateInSamplePeriods(EstimateACF.java:104)
at <snip>
com.algoint.zante.BluetoothLeService.broadcastUpdate(BluetoothLeService.java:348)
at com.algoint.zante.BluetoothLeService.access$700(BluetoothLeService.java:50)
at com.algoint.zante.BluetoothLeService$1.onCharacteristicChanged(BluetoothLeService.java:243)
at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:438)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)
at android.os.Binder.execTransact(Binder.java:453)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jtransforms.fft.DoubleFFT_1D" on path: DexPathList[[dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-json_simple-1.1_9ec115b071c72fb6edf2028f7a57e4ae60bb5a65-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-dropbox-android-sdk-1.5.4_74a0c4010a6328c8c6443241412fa9c5c398a9ab-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-achartengine-1.1.0_0238cc7eb0f70b6065b267fb6df8a8f6b48a5319-classes.dex"],nativeLibraryDirectories=[/data/app/com.algoint.zante-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.algoint.libzante.AutoCorrelation.compute(AutoCorrelation.java:66)
at com.algoint.libzante.EstimateACF.estimateInSamplePeriods(EstimateACF.java:104)
at <snip>
com.algoint.zante.BluetoothLeService.broadcastUpdate(BluetoothLeService.java:348)
at com.algoint.zante.BluetoothLeService.access$700(BluetoothLeService.java:50)
at com.algoint.zante.BluetoothLeService$1.onCharacteristicChanged(BluetoothLeService.java:243)
at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:438)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)
at android.os.Binder.execTransact(Binder.java:453)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "org.jtransforms.fft.DoubleFFT_1D" on path: DexPathList[[zip file "/data/app/com.algoint.zante-2/base.apk"],nativeLibraryDirectories=[/data/app/com.algoint.zante-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Suppressed: java.lang.ClassNotFoundException: Didn't find class "org.jtransforms.fft.DoubleFFT_1D" on path: DexPathList[[dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.algoint.zante/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.
我已經導入jtransforms作爲源文件如下:
import org.jtransforms.fft.DoubleFFT_1D;
與正確的gradle這個條目:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/JTransforms-3.1-with-dependencies.jar')
}
和相應的Android工作室依賴性關係設置:
的項目編譯沒有一個錯誤,並在下面的線拋出和錯誤:
int n = 2 * nextPow2(x.length);
// Twice the number of elements are required: real and imaginary parts of the FFT are stored consecutively
double[] f = new double[2 * n];
System.arraycopy(x, 0, f, 0, x.length);
// FFT
DoubleFFT_1D fft = new DoubleFFT_1D((long) n); // ERROR ON THIS LINE
// Use "full" to avoid more machinations with symmetry
fft.realForwardFull(f);
n個時引發錯誤的值是1024和x的長度是500。 我發現這個錯誤同時包含:「JTransforms-2.4.jar」和「JTransforms-3.1-with-dependencies.jar」。我認爲原始項目是在Maven編譯的,這是否有所作爲? 你能推薦任何解決方案嗎? 謝謝。
只是修復了代碼塊的格式問題。 – Hephaestus
問題是否解決了您的問題?解決方案是否解決您的問題?答案在http://stackoverflow.com/questions/11845451/exception-when-using-jtransform-in-android-java-lang-noclassdeffounderror-edu是否解決了您的問題? –
它沒有幫助。主要是因爲這些指令是用於eclipse的,而我正在使用Android Studio。 – Hephaestus