rpa*_*abi 14 android android-ndk renderscript android-support-library android-rendering
我正在使用renderscript进行音频dsp处理.它运行良好,直到我决定将renderscriptTargetApi
版本从19提升到24,试图以向后兼容的方式使用更新的renderscript API.
编译没有问题,但在运行时,logcat会显示这样的错误
05-31 19:40:23.097 8661-8734/com.example.audio.test E/RenderScript:无法打开共享库(/data/user/0/com.example.audio.test//lib/librs.xx .so):dlopen失败:未找到库"libRSSupportIO.so"
如果我有renderscriptTargetApi
19或20,我的apk有librs.xx.so
没有错误.如果我将它碰到21,23或24,librs.xx.so
则不会生成,因此我有此运行时错误.
我正在通过NDK使用renderscript,即C++.也使用CMake.我没有找到通过NDK使用renderscript支持库的指令.所有指令都假定支持库是通过Java使用的.
这是来自 build.gradle
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
renderscriptNdkModeEnabled true
Run Code Online (Sandbox Code Playgroud)
CMakeLists.txt
具有
add_library (dsp SHARED
${SRC_PATH}/dsp.cpp
${SRC_RS_PATH}/xx.rs ${SRC_RS_GENERATED_PATH}/ScriptC_xx.cpp)
target_compile_options(dsp PRIVATE
-std=c++11 -stdlib=libc++ -fno-rtti -fexceptions -Ofast)
target_link_libraries(dsp RScpp_static dl ${log-lib})
Run Code Online (Sandbox Code Playgroud)
这是 xx.rs
#pragma version(1)
#pragma rs java_package_name(com.example.audio)
#pragma rs_fp_relaxed
float RS_KERNEL my_kernel(float in, uint32_t x) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
这就是从C++调用内核的方式
sp<RS> rs = new RS();
rs->init(app_cache_dir);
sp<const Element> e = Element::F32(rs);
sp<const Type> t = Type::create(rs, e, 44100*10, 0, 0);
sp<Allocation> inAlloc = Allocation::createTyped(rs, t);
inAlloc->copy1DFrom(input);
sp<Allocation> outAlloc = Allocation::createTyped(rs, t);
ScriptC_xx *script = new ScriptC_xx(rs);
script->forEach_xx(inAlloc, outAlloc);
outAlloc->copy1DTo(output);
Run Code Online (Sandbox Code Playgroud)
如您所见,这是renderscript的基本使用场景.它renderscriptTargetApi
在19或20中运行良好.如果我提升版本,构建仍然成功,但librs.xx.so
不生成文件.在运行时,我们看到有关此.so文件的上述错误.
我在这里错过了什么?我试着操纵我minSdkVersion
认为与renderscript target api无关的我.它没有帮助.
如何以NDK的向后兼容方式使用较新的renderscript API?任何帮助表示赞赏.
https://github.com/rpattabi/renderscript-ndk-cmake
我已经就Android构建系统提交了一份关于此问题的错误报告:https://issuetracker.google.com/issues/109578956
归档时间: |
|
查看次数: |
408 次 |
最近记录: |