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

Android crash with amplitudesFromAudioJNI #36

Closed
devvuphan opened this issue Jan 18, 2022 · 11 comments · Fixed by #26 or #39
Closed

Android crash with amplitudesFromAudioJNI #36

devvuphan opened this issue Jan 18, 2022 · 11 comments · Fixed by #26 or #39
Assignees
Labels
help wanted Extra attention is needed

Comments

@devvuphan
Copy link

devvuphan commented Jan 18, 2022

I'm trying to apply waveformSeekBar + Amplituda to my project. Your description is very cool. But i can't run it with mp3 raw folder.

Added:

implementation  'com.github.massoudss:waveformSeekBar:4.1.0'
implementation 'com.github.lincollincol:amplituda:2.1.0' // or newer version

maven { url 'https://jitpack.io' }

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.INTERNET" />

android:extractNativeLibs="false"

<com.masoudss.lib.WaveformSeekBar
     android:id="@+id/waveformSeekBar"
     android:layout_width="match_parent"
     android:layout_height="@dimen/_50sdp"
     android:layout_marginStart="@dimen/_12sdp"
     android:layout_marginTop="@dimen/_4sdp"
     android:layout_marginEnd="@dimen/_12sdp"
     android:layout_marginBottom="@dimen/_4sdp"
    app:wave_background_color="@color/colorAccent"
    app:wave_corner_radius="2dp"
    app:wave_gap="2dp"
    app:wave_gravity="center"
    app:wave_max_progress="100"
    app:wave_min_height="5dp"
    app:wave_progress="33"
    app:wave_progress_color="@color/colorPrimary"
    app:wave_width="5dp" />

waveformSeekBar.setSampleFrom(R.raw.test_audio)

And i got this error:

java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: JNI GetFieldID called with pending exception java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "amplitudes" in class "Llinc/com/amplituda/AmplitudaResultJNI;" or its superclasses
java_vm_ext.cc:577]   at linc.com.amplituda.AmplitudaResultJNI linc.com.amplituda.Amplituda.amplitudesFromAudioJNI(java.lang.String) (Amplituda.java:-2)
java_vm_ext.cc:577]   at linc.com.amplituda.AmplitudaResultJNI linc.com.amplituda.Amplituda.c(java.io.File, linc.com.amplituda.e) (Amplituda.java:51)
java_vm_ext.cc:577]   at linc.com.amplituda.b linc.com.amplituda.Amplituda.a(int) (Amplituda.java:146)
java_vm_ext.cc:577]   at void com.masoudss.lib.d.c.a(android.content.Context, int, f.b0.c.l) (WaveformOptions.kt:17)
java_vm_ext.cc:577]   at void com.masoudss.lib.WaveformSeekBar.setSampleFrom(int) (WaveformSeekBar.kt:144)

Are there any changes i need to do more? Or i missed any guideline?

Thank you.

@lincollincol
Copy link
Owner

Hi @devvuphan. Please, provide this raw mp3 file. I'd like to test it

@devvuphan
Copy link
Author

thanks for you feedback.
It's a file i copied from internet. Are there any requires for the audio file to use with your lib?
https://tainhac123.com/tai-bai-hat-de-vuong-dinh-dung-ft-acv-mp3/w8lmuII1Yn2G.html

@lincollincol
Copy link
Owner

Hmm, library processed file without errors.

I/System.out: Start Progress
I/System.out: Decode resource: 1% 
I/System.out: Decode resource: 2% 
// ...
I/System.out: Decode resource: 99% 
I/System.out: Decode resource: 100% 
I/System.out: Process audio: 1% 
I/System.out: Process audio: 2% 
// ...
I/System.out: Process audio: 99% 
I/System.out: Process audio: 100% 
I/System.out: Stop Progress
I/System.out: Audio info:
    millis = 262031
    seconds = 262
    source = 2131492864
    source type = RESOURCE
    Amplitudes:
    size: = 266
    list: = [0, 0, 5, 5, 6, 3, 5, 5, 6, 5, 11, 8, 10, 6, 8, 9, 11, 10, 15, 15, 9, 5, 17, 13, 9, 6, 14, 13, 10, 3, 15, 15, 11, 4, 13, 14, 14, 4, 14, 17, 11, 4, 14, 17, 14, 4, 14, 17, 14, 5, 26, 33, 34, 19, 30, 29, 29, 25, 28, 32, 31, 26, 23, 33, 29, 32, 19, 34, 33, 29, 27, 32, 32, 29, 26, 38, 33, 32, 25, 37, 33, 32, 32, 32, 24, 32, 27, 32, 26, 20, 15, 24, 24, 35, 28, 32, 29, 25, 19, 24, 20, 20, 10, 25, 18, 23, 6, 26, 15, 26, 5, 29, 14, 26, 6, 12, 15, 18, 7, 15, 14, 16, 7, 12, 17, 17, 8, 12, 18, 20, 16, 16, 38, 37, 34, 32, 36, 35, 33, 33, 32, 32, 28, 22, 31, 32, 33, 19, 34, 34, 33, 22, 37, 28, 35, 19, 38, 32, 37, 24, 36, 32, 34, 32, 34, 29, 31, 33, 33, 30, 23, 13, 22, 31, 33, 34, 36, 32, 28, 17, 26, 35, 33, 28, 29, 33, 29, 32, 30, 34, 32, 29, 26, 37, 33, 35, 24, 35, 35, 30, 29, 33, 33, 31, 30, 40, 34, 34, 28, 37, 35, 33, 32, 34, 27, 49, 39, 39, 31, 47, 36, 32, 33, 38, 37, 43, 29, 36, 37, 23, 16, 22, 38, 42, 32, 37, 35, 43, 34, 38, 36, 39, 41, 28, 17, 17, 11, 10, 6, 9, 14, 10, 5, 8, 16, 10, 12, 10, 14, 13, 12, 9, 4, 1, 0, 0]

Please, try to process this file directly with Amplituda. You can use java code below:

        Amplituda amplituda = new Amplituda(this);

        amplituda.processAudio(
                R.raw.test,
                Compress.withParams(Compress.AVERAGE, 1),
                new AmplitudaProgressListener() {
                    @Override
                    public void onStartProgress() {
                        super.onStartProgress();
                        System.out.println("Start Progress");
                    }

                    @Override
                    public void onStopProgress() {
                        super.onStopProgress();
                        System.out.println("Stop Progress");
                    }

                    @Override
                    public void onProgress(ProgressOperation operation, int progress) {
                        String currentOperation = "";
                        switch (operation) {
                            case PROCESSING: currentOperation = "Process audio"; break;
                            case DECODING: currentOperation = "Decode resource"; break;
                            case DOWNLOADING: currentOperation = "Download audio from url"; break;
                        }
                        System.out.printf("%s: %d%% %n", currentOperation, progress);
                    }
                }
        ).get(result -> { printResult(result);
        }, exception -> { exception.printStackTrace(); });

@lincollincol lincollincol self-assigned this Jan 18, 2022
@lincollincol lincollincol added the help wanted Extra attention is needed label Jan 18, 2022
@devvuphan
Copy link
Author

Thanks lincollincol. I will try with your code

@henockbongi
Copy link

Hello,
i get this message error when i build my app in release mode.

No pending exception expected: java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "amplitudes" in class "Llinc/com/amplituda/AmplitudaResultJNI;" or its superclasses.
But app correctly works on Dev build. What should i do?

Thanks!

@lincollincol lincollincol linked a pull request Feb 3, 2022 that will close this issue
@lincollincol
Copy link
Owner

Hello! Please, update Amplituda to 2.1.3 and try again
implementation 'com.github.lincollincol:Amplituda:2.1.3'
@henockbongi @devvuphan

@henockbongi
Copy link

Hello,

I tried but still not works i don't know why

@henockbongi
Copy link

Hmm, library processed file without errors.

I/System.out: Start Progress
I/System.out: Decode resource: 1% 
I/System.out: Decode resource: 2% 
// ...
I/System.out: Decode resource: 99% 
I/System.out: Decode resource: 100% 
I/System.out: Process audio: 1% 
I/System.out: Process audio: 2% 
// ...
I/System.out: Process audio: 99% 
I/System.out: Process audio: 100% 
I/System.out: Stop Progress
I/System.out: Audio info:
    millis = 262031
    seconds = 262
    source = 2131492864
    source type = RESOURCE
    Amplitudes:
    size: = 266
    list: = [0, 0, 5, 5, 6, 3, 5, 5, 6, 5, 11, 8, 10, 6, 8, 9, 11, 10, 15, 15, 9, 5, 17, 13, 9, 6, 14, 13, 10, 3, 15, 15, 11, 4, 13, 14, 14, 4, 14, 17, 11, 4, 14, 17, 14, 4, 14, 17, 14, 5, 26, 33, 34, 19, 30, 29, 29, 25, 28, 32, 31, 26, 23, 33, 29, 32, 19, 34, 33, 29, 27, 32, 32, 29, 26, 38, 33, 32, 25, 37, 33, 32, 32, 32, 24, 32, 27, 32, 26, 20, 15, 24, 24, 35, 28, 32, 29, 25, 19, 24, 20, 20, 10, 25, 18, 23, 6, 26, 15, 26, 5, 29, 14, 26, 6, 12, 15, 18, 7, 15, 14, 16, 7, 12, 17, 17, 8, 12, 18, 20, 16, 16, 38, 37, 34, 32, 36, 35, 33, 33, 32, 32, 28, 22, 31, 32, 33, 19, 34, 34, 33, 22, 37, 28, 35, 19, 38, 32, 37, 24, 36, 32, 34, 32, 34, 29, 31, 33, 33, 30, 23, 13, 22, 31, 33, 34, 36, 32, 28, 17, 26, 35, 33, 28, 29, 33, 29, 32, 30, 34, 32, 29, 26, 37, 33, 35, 24, 35, 35, 30, 29, 33, 33, 31, 30, 40, 34, 34, 28, 37, 35, 33, 32, 34, 27, 49, 39, 39, 31, 47, 36, 32, 33, 38, 37, 43, 29, 36, 37, 23, 16, 22, 38, 42, 32, 37, 35, 43, 34, 38, 36, 39, 41, 28, 17, 17, 11, 10, 6, 9, 14, 10, 5, 8, 16, 10, 12, 10, 14, 13, 12, 9, 4, 1, 0, 0]

Please, try to process this file directly with Amplituda. You can use java code below:

        Amplituda amplituda = new Amplituda(this);

        amplituda.processAudio(
                R.raw.test,
                Compress.withParams(Compress.AVERAGE, 1),
                new AmplitudaProgressListener() {
                    @Override
                    public void onStartProgress() {
                        super.onStartProgress();
                        System.out.println("Start Progress");
                    }

                    @Override
                    public void onStopProgress() {
                        super.onStopProgress();
                        System.out.println("Stop Progress");
                    }

                    @Override
                    public void onProgress(ProgressOperation operation, int progress) {
                        String currentOperation = "";
                        switch (operation) {
                            case PROCESSING: currentOperation = "Process audio"; break;
                            case DECODING: currentOperation = "Decode resource"; break;
                            case DOWNLOADING: currentOperation = "Download audio from url"; break;
                        }
                        System.out.printf("%s: %d%% %n", currentOperation, progress);
                    }
                }
        ).get(result -> { printResult(result);
        }, exception -> { exception.printStackTrace(); });

I also tried this code but Android Studio told me that it cannot resolve classes and asked me to create Amplituda Class

@henockbongi
Copy link

How can i try directly try to process file directly with Amplituda?
First, i will try to process from an url to see what will happened, then i'll tell you what i got.

@lincollincol lincollincol linked a pull request Feb 19, 2022 that will close this issue
@lincollincol
Copy link
Owner

Consumer rules updated in 2.1.4 version. So, this should solve the error

@devvuphan @henockbongi

@p-inemu
Copy link

p-inemu commented Oct 1, 2023

image
version 2.2.2 Still crashing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
4 participants