Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError: No static method readString in Android Studio with Java #19

Open
jejj1206 opened this issue Dec 28, 2023 · 1 comment

Comments

@jejj1206
Copy link

When I try to use the bindings in Android Studio with Java, I get the following error:

java.lang.NoSuchMethodError: No static method readString(Ljava/nio/file/Path;)Ljava/lang/String; in class Ljava/nio/file/Files; or its super classes (declaration of 'java.nio.file.Files' appears in /apex/com.android.art/javalib/core-oj.jar)
                                                                                                    	at io.github.givimad.whisperjni.internal.LibraryUtils.loadLibrary(LibraryUtils.java:136)
                                                                                                    	at io.github.givimad.whisperjni.WhisperJNI.loadLibrary(WhisperJNI.java:384)
                                                                                                    	at com.example.myapplication.MainActivity.onCreate(MainActivity.java:235)
                                                                                                    	at android.app.Activity.performCreate(Activity.java:8595)
                                                                                                    	at android.app.Activity.performCreate(Activity.java:8573)
                                                                                                    	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
                                                                                                    	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
                                                                                                    	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
                                                                                                    	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Does anyone know how to solve this issue?

Below is my code:

WhisperJNI.LoadOptions loadOptions = new WhisperJNI.LoadOptions();
// Provide path to libwhisper so/dylib file.
loadOptions.whisperLib = libsDir.resolve("libwhisper.so");
// register the library
WhisperJNI.loadLibrary(loadOptions);
WhisperJNI.setLibraryLogger(null); // capture/disable whisper.cpp log
WhisperJNI whisper = new WhisperJNI();
WhisperContext ctx = whisper.init(modelsDir.resolve("ggml-tiny.bin"));
WhisperFullParams params = new WhisperFullParams();
float[] samples = decodeWaveFile(outputPath.resolve("out.wav").toFile());
int result = whisper.full(ctx, params, samples, samples.length);
@purgeme
Copy link

purgeme commented Jun 10, 2024

Hey, did you resolve this issue or find a workaround ? I am facing the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants