【发布时间】:2015-01-20 23:22:37
【问题描述】:
我想从使用 Android NDK 编译的 C++ 代码中使用 Renderscript。我构建了 NDK 附带的“HelloComputeNDK”示例。它在 Lollipop 设备上运行良好,但在 KitKat (4.4.4) 上崩溃并在 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
我在 AndroidManifest.xml 中设置了minSdkVersion="14",在 Application.mk 中设置了APP_PLATFORM := android-19,在 Android.mk 中设置了TARGET_PLATFORM := android-19。我使用以下方法构建示例:
android update project --name HelloComputeNDK --path . --target android-19
ndk-build clean
ndk-build -d
ant -verbose debug install
我在其他地方看到过类似的崩溃,但这些情况下的问题是缺少APP_PLATFORM 或TARGET_PLATFORM。这似乎不是这里的问题。
我相信我和这个人有同样的问题:https://stackoverflow.com/questions/27704847/ndk-sample-project-hellocomputendk-crashes,https://stackoverflow.com/questions/27705350/ndk-sample-project-hellocomputendk-problems。我认为这个问题被否决了,因为用户发布了两个似乎重复的问题。我有同样的问题,我认为这是一个合理的问题,所以我在这里问。
编辑
我正在使用 SDK 构建工具版本 21.1.2 和 NDK r10d。
在拉里·希弗回答后编辑
我还尝试在 project.properties 中添加以下内容:
renderscript.target=19
renderscript.support.mode=true
这会给出错误“sdklib.build.DuplicateFileException: Duplicate files at the same path within the APK”,因为 HelloComputeNDK 示例明确包含“Android.mk”中的 RenderScript 支持库:
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 崩溃。
【问题讨论】:
标签: android android-ndk renderscript