I am trying to write an Android app that uses the Lame mp3 encoder. My development environment is Android Studio 1.1.
Following the hints under Lame MP3 Encoder compile for Android I managed to install the Android NDK and compile Lame. Under /app/src/main/libs/armeabi I obtained the shared object "libmp3lame.so", with
libmp3lame.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped.
However, trying to load this file in a simple Android Studio project, utilizing
static {
System.loadLibrary("mp3lame");
}
always results in the following error:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/.../base.apk"],nativeLibraryDirectories=[/data/app/.../lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libmp3lame.so"
I also tried to load the file with
System.load(*full file name*);
but this resulted in the same error.
From what I've read so far I assume that this is a gradle issue but I have no clue how to solve that. Any help will be much appreciated!
My Android.mk looks like this
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libmp3lame
LOCAL_SRC_FILES := \
./libmp3lame/bitstream.c \
./libmp3lame/encoder.c \
./libmp3lame/fft.c \
./libmp3lame/gain_analysis.c \
./libmp3lame/id3tag.c \
./libmp3lame/lame.c \
./libmp3lame/mpglib_interface.c \
./libmp3lame/newmdct.c \
./libmp3lame/presets.c \
./libmp3lame/psymodel.c \
./libmp3lame/quantize.c \
./libmp3lame/quantize_pvt.c \
./libmp3lame/reservoir.c \
./libmp3lame/set_get.c \
./libmp3lame/tables.c \
./libmp3lame/takehiro.c \
./libmp3lame/util.c \
./libmp3lame/vbrquantize.c \
./libmp3lame/VbrTag.c \
./libmp3lame/version.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
And this is my build.gradle
apply plugin: 'com.android.application'
android { compileSdkVersion 21 buildToolsVersion "21.1.2"
defaultConfig {
applicationId "eu.martinloeser.android.lamefromscratch"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
As I said before, any help will be much appreciated!