如何链接的"跛脚" MP3连接codeR共享对象到Android Studio项目 [英] How to link the "lame" mp3 encoder shared object to an Android studio project
问题描述
我尝试编写使用跛脚MP3连接codeR Android应用程序。我的发展
环境的是Android 1.1工作室
I am trying to write an Android app that uses the Lame mp3 encoder. My development environment is Android Studio 1.1.
继下的提示
跛脚MP3恩codeR编译为Android
我设法安装Android NDK和编译跛。下
的 /应用/ src目录/主/库/ armeabi 的
我所获得的共享对象libmp3lame.so,用
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位LSB的共享对象,ARM版本1(SYSV),动态链接(使用共享库),剥去
libmp3lame.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), stripped.
但是,试图加载该文件在一个简单的Android Studio项目,利用
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文件/data/app/.../base.apk\"],nativeLibraryDirectories=[/data/app/.../lib/ arm64,/供应商/ lib64下,/系统/ lib64目录]]]找不到libmp3lame.so
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"
我也试图装入文件
System.load(*full file name*);
但是这导致了同样的错误。
but this resulted in the same error.
据我至今读我认为这是一个问题的Gradle,但我不知道如何解决。任何帮助将大大AP preciated!
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!
我的Android.mk看起来像这样
My Android.mk looks like this
LOCAL_PATH:= $(叫我-DIR)
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)
这是我的build.gradle
And this is my build.gradle
应用插件:'com.android.application
apply plugin: 'com.android.application'
安卓{
compileSdkVersion 21
buildToolsVersion21.1.2
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'
}
正如我以前说过,任何帮助将大大AP preciated!
As I said before, any help will be much appreciated!
推荐答案
感谢您的反馈意见。我终于得到它的工作。关键在于对build.gradle'文件中。
Thanks for your feedback. I finally got it to work. The key lies inside the 'build.gradle'-file.
在'defaultConfig'节你一定要告诉你要链接跛脚Android的工作室。因此,添加
In the 'defaultConfig'-section you have to tell Android studio that you want to link lame. Therefore, add
ndk{
moduleName "Lame"
ldLibs "log"
}
这奏效了我: - )
干杯,
马丁
这篇关于如何链接的"跛脚" MP3连接codeR共享对象到Android Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!