访问 flutter asset 到本地共享库

问题描述 投票:0回答:0

我在用 flutter 开发的项目中使用本机代码 (c++11)。但我需要访问本机代码中的资产。该文件是经过训练的数据模型,扩展名为 .bin 。你能帮帮我吗?

    std::string model = "../models/dataset.bin";

我尝试了不同的目录,但我无法访问它。我构建了项目并打开了生成的 apk 文件并相应地给出了目录。

例如: 结果,我的 Cmake 文件生成了 libwhisper.so 文件,因此 dataset.bin 应该可以访问它。 我试过了

../../assets/flutter/assets/models/dataset.bin
.

CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
project(whisper)

set(CMAKE_CXX_STANDARD 11)

add_library(whisper SHARED library.cpp whisper.h whisper.cpp ggml.c ggml.h common.cpp common.h dr_wav.h)
find_library( # Defines the name of the path variable that stores the
        # location of the NDK library.
        log-lib

        # Specifies the name of the NDK library that
        # CMake needs to locate.
        log )
# Links your native library against one or more other native libraries.
target_link_libraries( # Specifies the target library.
        whisper

        # Links the log library to the target library.
        ${log-lib} )
flutter shared-libraries ffi dart-ffi
© www.soinside.com 2019 - 2024. All rights reserved.