dlopen失败:无法找到libmyskia.so

时间:2018-10-25 08:19:21

标签: google-chrome cmake android-ndk java-native-interface skia

我正在尝试使用master分支为Android构建Skia。但是我遇到了以下错误:

  

java.lang.UnsatisfiedLinkError:dlopen失败:无法找到由“ ... / libmyskia.so”引用的符号“ _ZN11SkJpegCodec6IsJpegEPKvj” ...           在java.lang.Runtime.loadLibrary0(Runtime.java:1016)

一些细节:

1)建立Skia的命令:

#!/usr/bin/env bash

echo "generating ninja build files..."

bin/gn gen out/x86 --args='ndk="/Users/rowandjj/Library/Android/sdk/ndk-bundle/" target_cpu="x86" ndk_api=21 target_os="android" is_official_build=false is_component_build=true is_debug=false skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_libpng=false skia_use_icu=false skia_use_libjpeg_turbo=false skia_use_libwebp=false skia_use_piex=false'
echo "ninja compiling and linking..."
/usr/local/bin/ninja -C out/x86
echo "job done!"

2)CMakeLists:

cmake_minimum_required(VERSION 3.4.1)
set(distribution_DIR ${CMAKE_SOURCE_DIR}/libs)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/android)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/atlastext)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/c)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/codec)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/config)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/core)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/effects)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/encode)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/gpu)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/pathops)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/ports)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/private)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/svg)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/utils)

add_library( # Sets the name of the library.
        myskia

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        IMPORTED )


set_target_properties(
        myskia
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libmyskia.so
)

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)

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)

target_link_libraries( # Specifies the target library.
        native-lib

        myskia

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})

3)我的NDK版本:18.1.5063045

4)gradle版本:4.6 / gradle插件版本:3.2.1

5)build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.foo.android.helloskia"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                arguments "-DANDROID_PLATFORM=android-26"
                cppFlags "-frtti -fexceptions"
            }
        }

        ndk {
            abiFilters 'armeabi-v7a',"x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

    sourceSets {

        main {
            jniLibs.srcDir "./libs"
        }
    }
}

0 个答案:

没有答案