Android Question Record MP3/LibLame alternative

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Guys

We have an app that uses LibLame to convert recorded wave files (captured using AudioStreamer) into MP3 fles before sending them to remote device.

The problem we are facing now, is after upgrading to tagetSDK=26+, the app is failing on devices running Android 6.0 and lower ( or at least this is what we have noticed so far), and most likely it is due to the storage location.

What is the best alternative for this?

Thanks
iCAB
 

iCAB

Well-Known Member
Licensed User
Longtime User
sounds like you are not using it correctly then!? You are giving us ZERO Information so all we can do is guessing.

Hey Don, thanks for your reply
Just before I replied to this, I changed targetSDK=14, and I tried the code. I didn't face any issues.

Next I changed the TargetSDK = 26, I got the error.

On Stop Recording, I am calling this

B4X:
Private Sub VMR_StopRecordingImmediately( blnFireCallBack As Boolean )
    
    If blnRecording = False Then
        Return
    End If
    
    
    blnRecording = False
    SafetyTimer.Enabled = False
    
    blnSetFireCallBack = blnFireCallBack
    
    streamer.StopRecording
    output.Close

#if NOT(RUN_EMULATOR)   
    VMR_CloseWaveFile(GeneralLib.GL_GetTempFolder, WaveFileTempFileName)
    
'******************** This line generates the error after changing TargetSDK
    If LameEncoder.SetFiles(File.Combine(GeneralLib.GL_GetTempFolder, WaveFileTempFileName), File.Combine(GeneralLib.GL_GetTempFolder, Mp3FileTempFileName)) Then
        'LameEncoder.SetQuality(LameEncoder.LAME_PRESET_STANDARD)    '    adjust to suit
        LameEncoder.Encode
    Else
        If blnSetFireCallBack = True And ModuleDoneEvent <> "" Then
            CallSubDelayed3( JobEventTargetModule, ModuleDoneEvent, "", False )
        End If
    End If
#end If
    
End Sub


B4X:
Sub GL_GetTempFolder() As String

    Dim TempDir As String = ""
#if B4A   
    TempDir = File.DirInternalCache
#else
    TempDir = File.DirTemp
#End If
    Return TempDir
    
End Sub


Error output

B4X:
voicerecording_vmr_stoprecordingimmediately (B4A line: 177)
Return TempDir
java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.packagename/lib/arm/liblame.so: has text relocations
    at java.lang.Runtime.loadLibrary(Runtime.java:372)
    at java.lang.System.loadLibrary(System.java:1076)
    at net.sourceforge.lame.Lame.<clinit>(Lame.java:36)
    at com.intervigil.lame.Encoder.initialize(Encoder.java:52)
    at uk.co.martinpearman.b4a.liblame.EncoderWrapper.SetFiles(EncoderWrapper.java:92)
    at com.packagename.voicerecording._vmr_stoprecordingimmediately(voicerecording.java:575)
    at com.packagename.voicerecording._safetytimer_tick(voicerecording.java:231)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
    at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
    at android.os.Handler.handleCallback(Handler.java:745)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:174)
    at android.app.ActivityThread.main(ActivityThread.java:5440)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
This is a common problem with older binaries (native libs = so-files such as "liblame.so" in your case). Google added some checks some time ago and now requires that said binaries are recompiled to adhere to their requirements. This happened to many libs using non-adhering binaries.

The solutions are either targeting a lower SDK-version (which is probably not going to resolve your problems since Google will soon require that apps are set to targetSdkVersion to 26+) or the binary/library (not the wrapper) is being recompiled to adhere to the new requisites. I don't think @warwound could do anything about it even he wanted to unless the code for compiling the binary is ready-available. If you are lucky, the author of the library, that was wrapped by @warwound, may have recompiled the sources and then the library could be re-wrapped including the updated binaries.

Edit: a long shot: If the author did recompile the binaries, then get hold of them and if you are lucky you could unzip the wrapper and replace the binaries and then zip-compress it again although most of the times this approach will fail....
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
You could of course use my ffmpeg-encoder which can convert wave to mp3. There may be other alternatives.
If you are interested, send me a PM.

Hi Moster67, thanks for your offer , it is greatly appreciated and it is good to know that there is an alternative.
However my main goal, is to be able to send voice messages between apps (iOS & Android) with the least overhead possible and smallest file size.

I am wondering if we can use AudioRecorder for that. I just need to experiment a bit with it, to see if 3GPP format is supported on iOS and also need compare the file size and voice quality.

Anyone with experience with the above, please share your findings.

Tanks
iCAB
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
The problem we are facing now, is after upgrading to tagetSDK=26+, the app is failing on devices running Android 6.0 and lower...

Did you mean to say that it fails with Android 6 AND HIGHER?

I ask because it's failing with Android 7.1.1, but works with Android 5.0.1
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Did you mean to say that it fails with Android 6 AND HIGHER?

I ask because it's failing with Android 7.1.1, but works with Android 5.0.1
To be more specific, I don't have an android 6 on hand.
I only have 5.x and 7.x, so I shouldn't say anything about android 6
 
Last edited:
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User

Yes Liblame library does not support android ver 8.1.1 although on 4.1.1 it does work.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…