如何解决UnsatisfiedLinkError? [英] How to solve UnsatisfiedLinkError?

查看:523
本文介绍了如何解决UnsatisfiedLinkError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio 3,并且试图在设备上使用OpenCL. APK会在以下位置编译并失败:

I'm using Android Studio 3 and I am trying to use OpenCL with my device. The APK compiles and fails at:

java.lang.UnsatisfiedLinkError:dlopen失败:未找到库"libcutils.so"

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

这是我的build.gradle:

This is my 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.

推荐答案

即使在设备的/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 :

应用程序不应使用NDK中未包含的本机库,因为它们可能会在不同版本的Android之间更改或删除.

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是私有NDK库之一.

libcutils.so is one the private NDK libraries.

如果该应用的目标API级别为24或更高,则您的应用将崩溃,因为您尝试访问私有库.请注意,您的应用将targetSdkVersion 28定位为28.

If the app targets API level 24 or higher, your app will crash because you are trying to access to the private libraries. Note that your app is targeting 28 by having targetSdkVersion 28.

这篇关于如何解决UnsatisfiedLinkError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆