I am attempting to use the JTransforms library to compute a math function (DoubleFFT_1D) in an Android app (using the latest Android Studio). I am using the .jar file provided from the JTransforms website and have imported it to the project. I have tried both JTransforms Revision 2.4 and 3.1. The code compiles with no errors, but when I get to the actual method call, I get the following error message:
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.
I have imported jtransforms as follows in the source file:
import org.jtransforms.fft.DoubleFFT_1D;
with the proper gradle entry:
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/JTransforms-3.1-with-dependencies.jar')
}
And corresponding Android Studio dependency setting:
The project compiles without an error and throws and error at the following line:
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);
The value of n when the error is thrown is 1024 and the length of x is 500. I have found this error with both: "JTransforms-2.4.jar" and "JTransforms-3.1-with-dependencies.jar". I think the original project was compiled in Maven, does that make a difference? Can you recommend any solutions? Thank you.