我刚刚将我的应用程序项目的最低SDK版本从21更改为24。现在,我的构建失败并显示以下消息:
Process 'command 'C:\Users\User\AppData\Local\Android\Sdk\build-tools\27.0.3\llvm-rs-cc.exe'' finished with non-zero exit value 1
更准确地说:
Execution failed for task ':app:compileDebugRenderscript'.Caused by: org.gradle.internal.UncheckedException: com.android.ide.common.process.ProcessException: Error while executing process C:\Users\User\AppData\Local\Android\Sdk\build-tools\27.0.3\llvm-rs-cc.exe with arguments {-O 3 -I...
我的渲染脚本文件如下:
histEq.rs:
#pragma version(1)
#pragma rs_fp_relaxed
#pragma rs java_package_name(one.realnote.app)
#include "rs_debug.rsh"
int32_t histo[256];
float remapArray[256];
int size;
//Method to keep the result between 0 and 1
static float bound (float val) {
float m = fmax(0.0f, val);
return fmin(1.0f, m);
}
uchar4 __attribute__((kernel)) root(uchar4 in, uint32_t x, uint32_t y) {
//Convert input uchar4 to float4
float4 f4 = rsUnpackColor8888(in);
//Get YUV channels values
float Y = 0.299f * f4.r + 0.587f * f4.g + 0.114f * f4.b;
float U = ((0.492f * (f4.b - Y))+1)/2;
float V = ((0.877f * (f4.r - Y))+1)/2;
//Get Y value between 0 and 255 (included)
int32_t val = Y * 255;
//Increment histogram for that value
rsAtomicInc(&histo[val]);
//Put the values in the output uchar4, note that we keep the alpha value
return rsPackColorTo8888(Y, U, V, f4.a);
}
uchar4 __attribute__((kernel)) remaptoRGB(uchar4 in, uint32_t x, uint32_t y) {
//Convert input uchar4 to float4
float4 f4 = rsUnpackColor8888(in);
//Get Y value
float Y = f4.r;
//Get Y value between 0 and 255 (included)
int32_t val = Y * 255;
//Get Y new value in the map array
Y = remapArray[val];
//Get value for U and V channel (back to their original values)
float U = (2*f4.g)-1;
float V = (2*f4.b)-1;
//Compute values for red, green and blue channels
float red = bound(Y + 1.14f * V);
float green = bound(Y - 0.395f * U - 0.581f * V);
float blue = bound(Y + 2.033f * U);
//Put the values in the output uchar4
return rsPackColorTo8888(red, green, blue, f4.a);
}
void init() {
//init the array with zeros
for (int i = 0; i < 256; i++) {
histo[i] = 0;
remapArray[i] = 0.0f;
}
}
void createRemapArray() {
//create map for y
float sum = 0;
for (int i = 0; i < 256; i++) {
sum += histo[i];
remapArray[i] = sum / (size);
}
}
mono.rs:
#pragma version(1)
#pragma rs java_package_name(uelordi.android.hellocomputendk_rs)
const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
void root(const uchar4 *v_in, uchar4 *v_out) {
float4 f4 = rsUnpackColor8888(*v_in);
float3 mono = dot(f4.rgb, gMonoMult);
*v_out = rsPackColorTo8888(mono);
}
mono2.rs:
#pragma version(1)
#pragma rs java_package_name(one.realnote.app)
rs_allocation gIn;
rs_allocation gOut;
rs_script gScript;
const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {
//uchar4 __attribute__((kernel)) root(uchar4 v_in) {
float4 f4 = rsUnpackColor8888(*v_in);
float3 mono = dot(f4.rgb, gMonoMult);
// return rsPackColorTo8888(mono);
uchar4 res = rsPackColorTo8888(mono);
// return res;
// return (uchar)(mono * 256);
}
uchar __attribute__((kernel)) toU8(uchar4 v_in) {
float4 f4 = convert_float4(v_in);
return (uchar)dot(f4.rgb, gMonoMult);
}
uchar4 __attribute__((kernel)) toU8_4(uchar v_in) {
return (uchar4)v_in;
}
void filter() {
rsForEach(gScript, gIn, gOut);
}
我已经将构建工具更新为28,将Gradle版本更新为4.6,但是已经尝试使用构建工具27进行相同的过程。我注意到,如果您选择API级别为24或更高,则renderscript会有一些更改,但是我没有如果我的代码文件中有API破坏了更改,那还不是很清楚。除此之外,我的renderscriptTargetApi
设置为18。