简体   繁体   English

android.support.v8.renderscript.RSRuntimeException:加载ScriptC脚本失败

[英]android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed

I've started to work with renderscript and wonder why it doesn't work on api 16 with support mode. 我开始使用renderscript,想知道为什么它在支持模式的api 16上不起作用。 For example in project https://github.com/harism/android_reimage in code : 例如在代码中的项目https://github.com/harism/android_reimage中:

scriptInvert = new ScriptC_invert(rs);

I catch Exception : 我抓到异常:

Caused by: android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed. 引起原因:android.support.v8.renderscript.RSRuntimeException:ScriptC脚本加载失败。 at android.support.v8.renderscript.ScriptC.(ScriptC.java:69) 在android.support.v8.renderscript.ScriptC。(ScriptC.java:69)

at io.github.harism.lib.reimage.ScriptC_invert.(ScriptC_invert.java:42) 在io.github.harism.lib.reimage.ScriptC_invert。(ScriptC_invert.java:42)

at io.github.harism.lib.reimage.ScriptC_invert.(ScriptC_invert.java:34) 在io.github.harism.lib.reimage.ScriptC_invert。(ScriptC_invert.java:34)

at io.github.harism.lib.reimage.ReImage.(ReImage.java:56) 在io.github.harism.lib.reimage.ReImage。(ReImage.java:56)

at io.github.harism.lib.reimage.ReImage.from(ReImage.java:45) 在io.github.harism.lib.reimage.ReImage.from(ReImage.java:45)

Does someone have any idea why can this happen? 有人知道为什么会发生这种情况吗?

Example of .rs code that failed ( https://github.com/harism/android_reimage/blob/master/reimage/src/main/rs/invert.rs ): 失败的.rs代码示例( https://github.com/harism/android_reimage/blob/master/reimage/src/main/rs/invert.rs ):

#pragma version(1)
#pragma rs java_package_name(io.github.harism.lib.reimage)
#pragma rs_fp_relaxed

void invert(uchar4 *inout, uint32_t x, uint32_t y) {
    inout->r = 0xFF - inout->r;
    inout->g = 0xFF - inout->g;
    inout->b = 0xFF - inout->b;
}

That's funny but I found a core of an issue... My .rs files was in library module. 这很有趣,但是我发现了一个问题的核心……我的.rs文件位于库模块中。 That caused an issue because internalCreate(rs, resources, resourceID) in ScriptC returned 0 (wasn't able to find raw .bc files). 这引起了一个问题,因为ScriptC中的internalCreate(rs,resources,resourceID)返回0(无法找到原始的.bc文件)。

Rename the RS function to be root if you'd like it to be automatically picked up as the kernel for your script. 如果希望自动将RS函数作为脚本的内核,请将其重命名为root Or, change it to be: 或者,将其更改为:

void __attribute__((kernel)) invert(uchar4 *inout, uint32_t x, uint32_t y)

You will likely also run into a problem since you are not specifying an explicit output allocation. 由于未指定显式的输出分配,因此您可能还会遇到问题。 With the second form, replace the void return value with uchar4 and be sure to set an output allocation in your java code. 使用第二种形式,用uchar4替换void返回值,并确保在Java代码中设置输出分配。

I think the issue here might be proguard stripping the code. 我认为这里的问题可能是保护者剥离了代码。 Can you try disabling proguard and/or updating it to not remove anything related to the RS support library (or your custom code)? 您可以尝试禁用proguard和/或对其进行更新以不删除与RS支持库(或您的自定义代码)相关的任何内容吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM