gpt4 book ai didi

android - 如何解决 UnsatisfiedLinkError?

转载 作者:行者123 更新时间:2023-11-29 23:41:22 27 4
gpt4 key购买 nike

我正在使用 Android Studio 3,并尝试在我的设备上使用 OpenCL。APK 编译失败:

java.lang.UnsatisfiedLinkError: dlopen failed: library "libcutils.so" not found

这是我的build.gradle:

apply plugin: 'com.android.application'
def appDir = getProjectDir().toString()
def includeDir = appDir + "/src/main/cpp/include/"
def libDir = appDir + "/src/main/jniLibs/"
def arm64lib = libDir + "/arm64-v8a/"
def armeabilib = libDir + "/armeabi-v7a/"

android {

compileSdkVersion 28
defaultConfig {
applicationId "com.example.miche.androidopencltest"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
cppFlags "-I${includeDir}".toString()
cppFlags '-std=c++11'
}
}

}

splits{
abi{
enable true
reset()
include "armeabi-v7a"
universalApk false
}
}


project.ext.versionCodes = ['armeabi-v7a': 1]


buildTypes {
release {
//minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

我哪里做错了?

编辑

即使在设备的/lib/文件夹中,我也找不到正确的 .so。

最佳答案

I can't find the right .so even in the /lib/ folder of the device.

根据 https://developer.android.com/about/versions/nougat/android-7.0-changes :

Apps should not use native libraries that are not included in the NDK because they may change or be removed between different versions of Android.

libcutils.so 是私有(private) NDK 库之一。

如果应用程序以 API 级别 24 或更高级别为目标,您的应用程序将崩溃,因为您正在尝试访问私有(private)库。请注意,您的应用通过 targetSdkVersion 28 定位到 28。

关于android - 如何解决 UnsatisfiedLinkError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51825635/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com