我試圖運行this項目。每次我運行該項目,我得到下面的錯誤:java.lang.UnsatisfiedLinkError中,而在Android的加載so庫工作室
java.lang.UnsatisfiedLinkError中:dlopen的失敗:/數據/app/path.androidspeakerrec-1/lib/arm/libndkspeaker.so:有文本重定位
該項目不加載* .so文件。我已將lib文件的位置更改爲jniLibs,但仍然遇到同樣的問題。
構建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.sharannya.androidspeakerrec"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
ndk {
abiFilters "armeabi-v7a","armeabi"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}
從Java代碼中調用
static {
try {
System.loadLibrary("ndkspeaker");
} catch (UnsatisfiedLinkError e) {
Log.e("Error in loading lib","Native code library failed to load" + e);
}
}
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ndkspeaker
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := lib_mfcc/abs.c \
lib_mfcc/abs1.c \
lib_mfcc/fft.c \
lib_mfcc/fi_fft.c \
lib_mfcc/fi_mfcc.c \
lib_mfcc/fi_mfcc_initialize.c \
lib_mfcc/fi_mfcc_rtwutil.c \
lib_mfcc/fi_mfcc_terminate.c \
lib_mfcc/log.c \
lib_mfcc/mfcc_bare.c \
lib_mfcc/mtimes1.c \
lib_mfcc/power1.c \
lib_mfcc/rt_nonfinite.c \
lib_mfcc/rtGetInf.c \
lib_mfcc/rtGetNaN.c \
lib_mfcc/sqrt.c \
lib_mfcc/sum.c \
SpeakerRecognizer.c
APP_ABI := armeabi
include $(BUILD_SHARED_LIBRARY)
的.so文件位於項目/應用/ src目錄/主/ jniLibs/armeabi 和project/app/src/main/jniLibs/armeabi-v7a
我該如何解決這個問題?