获取 llvm-rs-cc 进程错误,我做错了什么?

Getting llvm-rs-cc process error, What am I doing wrong?

我在尝试 运行 renderscript 反转图像时遇到以下错误

Process 'command '/home/sandesh/Applications/AndroidStudio/Android/Sdk/build-tools/29.0.2/llvm-rs-cc'' finished with non-zero exit value 1

JAVA:

        RenderScript rs = RenderScript.create(context);
    ScriptC_clone scriptC_clone = new ScriptC_clone(rs);


    Allocation inputAllocation = Allocation.createFromBitmapResource(
            rs, context.getResources(), R.drawable.image_1);
    Allocation outputAllocation = Allocation.createTyped(
            rs, inputAllocation.getType(),
            Allocation.USAGE_SCRIPT | Allocation.USAGE_IO_OUTPUT);
    scriptC_clone.invoke_process(inputAllocation, outputAllocation);

clone.rs:

#pragma version(1)
#pragma rs java_package_name(com.example.clone)


uchar4 RS_KERNEL invert(uchar4 in, uint32_t x, uint32_t y) {
   uchar4 out = in;
   out.r = 255 - in.r;
   out.g = 255 - in.g;
   out.b = 255 - in.b;
   return out;
}

void process(rs_allocation inputImage, rs_allocation outputImage) {
  const uint32_t imageWidth = rsAllocationGetDimX(inputImage);
  const uint32_t imageHeight = rsAllocationGetDimY(inputImage);
  rs_allocation tmp = rsCreateAllocation_uchar4(imageWidth, imageHeight);
  rsForEach(invert, inputImage, tmp);
}

GRADLE:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'
    defaultConfig {
    applicationId "com.example.clone"
    minSdkVersion 22
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    renderscriptTargetApi 19
    renderscriptSupportModeEnabled true

   }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
sourceSets {
    main {
        jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/']
        renderscript.srcDirs =['src/main/rs', 'src/main/rs/']
}     }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation project(path: ':openCVLibrary348')
    implementation 'com.google.android.material:material:1.0.0'
}

在此之上可能还有其他错误行(或在 Android Studio 的单独控制台中)。 运行 我自己在命令行上给了我这个:

sample.rscript:17:25: 错误:函数 'rsCreateAllocation_uchar4' 的隐式声明在 C99 中无效 sample.rscript:17:19: 错误:使用不兼容类型 'int'

的表达式初始化 'rs_allocation'(又名 'struct rs_allocation')

您需要达到 API 24 级或更高级别才能使用这些附加功能。当仅将 RS 定位到 API 19(比应用程序其余部分的最小值 API - 22 早)时,您不能使用它们。可以重写代码以支持较旧的 RS 版本,但您会失去这些很好的帮助程序。

header(和24API级别)可以在这里看到: https://android.googlesource.com/platform/frameworks/rs/+/refs/heads/master/script_api/include/rs_allocation_create.rsh#382