针对使用Renderscript从NDKçpre-棒棒糖设备++ [英] Targeting pre-lollipop devices using Renderscript from NDK C++
问题描述
我想用Renderscript从我编译使用Android NDK C ++ code。我建立了HelloComputeNDK样本附带的NDK。它运行在棒棒糖的设备很好,但以下消息崩溃的奇巧(4.4.4)在亚行logcat
:
I would like to use Renderscript from C++ code that I compile using the Android NDK. I built the "HelloComputeNDK" sample that ships with the NDK. It runs fine on Lollipop devices, but crashes on KitKat (4.4.4) with the following message on adb logcat
:
E/bcinfo (28302): Invalid API version: 21 is out of range ('11' - '19')
E/RenderScript(28302): Failed to translate bitcode from version: 21
E/rsC++ (28302): Internal error: Object id 0.
F/libc (28302): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 28317 (hellocomputendk)
I/DEBUG ( 363): Build fingerprint: 'htc/bm/htc_m8:4.4.4/KTU84P/401507.4:user/release-keys'
I/DEBUG ( 363): Revision: '0'
I/DEBUG ( 363): pid: 28302, tid: 28317, name: hellocomputendk >>> com.example.android.rs.hellocomputendk <<<
I/DEBUG ( 363): debuggerd: checkTellHTCSettings
I/DEBUG ( 363): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
我已经设置的minSdkVersion =在AndroidManifest.xml中,
中的应用.mk,而 APP_PLATFORM14
:=机器人-19 TARGET_PLATFORM:=在Android.mk的android-19
。我用构建示例:
I have set minSdkVersion="14"
in AndroidManifest.xml, APP_PLATFORM := android-19
in Application.mk, and TARGET_PLATFORM := android-19
in Android.mk. I build the sample using:
android update project --name HelloComputeNDK --path . --target android-19
ndk-build clean
ndk-build -d
ant -verbose debug install
我也看到了类似的事故在其他地方讨论,但在这种情况下,问题是缺少 APP_PLATFORM
或 TARGET_PLATFORM
。这并没有出现在这里成为问题
I have seen similar crashes discussed elsewhere, but the problem in those cases was a missing APP_PLATFORM
or TARGET_PLATFORM
. This does does not appear to be the problem here.
我相信我有同样的问题,因为这个人: NDK示例项目HelloComputeNDK崩溃 NDK示例项目HelloComputeNDK问题的。我想这个问题得到downvoted因为用户发布了两个这似乎是重复的。我有同样的问题,我相信这是一个合理的问题,所以我问在这里。
I believe I have the same problem as this person: NDK Sample Project HelloComputeNDK Crashes, NDK Sample Project HelloComputeNDK Problems. I think that question got downvoted because the user posted two that appeared to be duplicates. I have the same problem and I believe it is a legitimate question so I am asking it here.
我使用的SDK构建工具版本21.1.2和NDK r10d。
I am using SDK build tools version 21.1.2 and NDK r10d.
我也尝试添加在project.properties以下内容:
I also tried adding the following in project.properties:
renderscript.target=19
renderscript.support.mode=true
这给出了错误sdklib.build.DuplicateFileException:重复的文件,在里面APK相同的路径,因为HelloComputeNDK例子显式包括Android.mk的RenderScript支持库:
This gives the error "sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK" because the HelloComputeNDK example explictly includes the RenderScript support library in "Android.mk":
include $(CLEAR_VARS)
LOCAL_MODULE := RSSupport
LOCAL_SRC_FILES := $(SYSROOT_LINK)/usr/lib/rs/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
include $(PREBUILT_SHARED_LIBRARY)
如果我从Android.mk删除这些线路的例子建立并成功安装和我以前一样得到同样的API 21死机。
If I remove those lines from Android.mk the example builds and install successfully and I get the same API 21 crash as before.
推荐答案
这是由于NDK构建一个错误,其不通过-target-API 19到LLVM-RS-CC。由于NDK R9B第一RS的支持,RenderScript主机工具(bcc_compat,LLVM-RS-C等,给K分公司编制,API 19)未更新,直到R10C当他们从L个分支(API 21)重修。如果没有明确的选项-target-API N,LLVM-RS-CC在R10C +使用默认的API,它是21,并且在logcat中看到无法在奇巧的bcinfo版本检查。
This is due to a bug in ndk-build which doesn't pass "-target-api 19" to llvm-rs-cc. Since the first RS support in NDK r9b, the RenderScript host tools (bcc_compat, llvm-rs-c, etc, compiled from K branch, API 19) weren't updated until r10c when they were rebuilt from L branch (API 21). Without the explicit option "-target-api N", llvm-rs-cc in r10c+ uses the default API which is 21, and fail version check in Kitkat's bcinfo as seen in logcat.
修复被提交,并将于NDK r10e或更高版本: https://开头的android -review.googlesource.com/#/c/124641
Fix is submitted and will be available in NDK r10e or later: https://android-review.googlesource.com/#/c/124641
这篇关于针对使用Renderscript从NDKçpre-棒棒糖设备++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!