dalvik.system.PathClassLoader[DexPathList[[zip file xxx ]] couldn't find "libplayer.so"

AndriodStudio集成 FFmpeg環境,報錯:java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.player-Bhalv81bWdaEyxPpDfXPvg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.player-Bhalv81bWdaEyxPpDfXPvg==/lib/arm64, /system/lib64, /product/lib64]]] couldn't find "libplayer.so"

我的CMakeList文件配置

cmake_minimum_required(VERSION 3.4.1)

# 目錄下所有的`.cpp`文件都需要被編譯,並保存到全局變量`SOURCE`中。
file(GLOB SOURCE *.cpp)

# 將SOURCE變量中的源文件編譯到 player動態庫中
add_library(
        player
        SHARED
        ${SOURCE})


find_library(
        log-lib
        log)

#設置頭文件的目錄。
#編譯的時候需要用到的頭文件,編譯後頭文件不會打包到目標庫中。這樣的話,在native-lib中可以直接引用頭文件。
include_directories(include)

# 標誌位, clang這個編譯期來構建

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${CMAKE_SOURCE_DIR}/../../../libs/${CMAKE_ANDROID_ARCH_ABI}")

# 將armeabi-v7a目錄下的靜態庫文件,鏈接到動態庫`player`中。
# 將會去編譯環境目錄去找 avfilter avformat ...等靜態庫,所以需要配置編譯環境路徑
target_link_libraries(
        player
        avfilter avformat avcodec avutil swresample swscale
        ${log-lib})

app的build.gradle文件

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.player"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
                abiFilters "armeabi-v7a"
            }
        }


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}

修改 app 的build.gradle文件

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.player"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
                abiFilters "armeabi-v7a"
            }
        }
        ndk{
            abiFilters "armeabi-v7a"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章