应用程序在模拟器上运行良好,但在设备上崩溃:java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__ae
Posted
技术标签:
【中文标题】应用程序在模拟器上运行良好,但在设备上崩溃:java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memcpy"【英文标题】:App works fine on emulators, but crashes on device with: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memcpy" 【发布时间】:2019-05-29 13:00:44 【问题描述】:我正在尝试使用 android Studio 3.2.1 将 yctung 的 AndroidLibSvm 实施到我的项目中。虽然该应用程序在任何模拟设备上都可以正常运行(我尝试了 Android 23 和 28,两者都完美运行),但它在我的真实设备(Android 6.0 的联想平板电脑)上崩溃并出现以下错误:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memcpy" referenced by "/data/app/com.krautkremer.nils.mymirror-2/lib/arm/libjnilibsvm.so"
只要应用程序尝试运行使用 cytung 库的部分代码。 SO上有一些类似的案例,例如here 或 here 但设置我的
arguments "-DANDROID_PLATFORM=android-23"
或任何其他 android-x 和我的 build.gradle 中的 targetSdkVersion 到 23 都没有解决它。
这是我的 build.gradle:
apply plugin: 'com.android.application'
android
compileSdkVersion 28
defaultConfig
applicationId "com.krautkremer.nils.mymirror"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild
cmake
cppFlags ""
arguments "-DANDROID_PLATFORM=android-23"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
packagingOptions
//exclude 'META-INF/proguard/androidx-annotations.pro'
externalNativeBuild
cmake
path "CMakeLists.txt"
dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.media:media:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ml-vision:18.0.2'
implementation 'com.google.firebase:firebase-ml-common:16.1.6'
implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1-alpha01'
implementation project(':androidlibsvm-release')
apply plugin: 'com.google.gms.google-services'
我什至将我的 NDK 版本从 18 降级到 15,但没有成功。 任何想法可能是什么问题?
帮帮我,欧比旺·克诺比。你是我唯一的希望。
编辑: 这是我的 CMakeLists.txt,如果有帮助的话。我没有改变任何东西,不是吗?
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
$log-lib)
【问题讨论】:
如果 LibSVM 崩溃,请确保您的输入选项遵循原始 LibSVM 格式 感谢您的回复。但是,即使应用程序在模拟设备上运行良好,输入格式/选项是否也有问题? 【参考方案1】:尝试改变你的minSdkVersion和targetSdkVersion,即
minSdkVersion 15
targetSdkVersion 23
【讨论】:
感谢您的帮助!我尝试了一堆最小和目标 Sdkversion 的组合,但都没有奏效。 没必要。它在 API 级别 23 的 Android 6.0 上崩溃。上面显示的 minSdkVersion 应该没问题。以上是关于应用程序在模拟器上运行良好,但在设备上崩溃:java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__ae的主要内容,如果未能解决你的问题,请参考以下文章
React-Native 应用程序在 android 设备上立即崩溃,但在模拟器上运行良好
应用程序在模拟器上运行良好,但在设备上崩溃:java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__ae
在flutter中从image_picker包中打开相机会导致真实设备上的应用程序崩溃,但在模拟器(android)中运行良好
IOs App 在模拟器上运行但在设备上崩溃(主要使用 AVFoundation)
Flutter App 在模拟器(Iphone 12 mini)上完美运行,但在设备上崩溃(Iphone 8 plus)