user2515310
user2515310

Reputation: 377

Error with renderscript on android studio 0.2.2

I have been attempting to run the HelloCompute sample given in the sample code package, and I have run into a problem.

I put all the renderscript code in a file called "mono.rs" as below (with my package name of course)

Regardless, whenever I attempt to reference the java class that is supposed to have been reflected from this file, using the statement

private ScriptC_mono mScript;

I get an error which says that android studio "Cannot resolve symbol 'ScriptC_mono'".

Is there something wrong with my approach. is there some way to make the renderscript file reflect itself. I found something about a renderscript error in a recent bug report but it appeared to have been fixed in 22.0.4.

Upvotes: 2

Views: 1243

Answers (1)

Steelight
Steelight

Reputation: 3357

After about three days of struggling with this, I found that the problem was with the project folder structure, when compiling with gradle. This project shows the correct structure:

https://android.googlesource.com/platform/tools/build/+/11086782041b302109e8349e13b8f9d5e305341d/tests/renderscript/

In short, the .rs files should not be together with the java files, but in a separate folder called 'rs' alongside java and res, with the same inside structure, such as "...\HelloRSProject\HelloRS\src\main\rs\com\example\hellors\mono.rs". Also, be sure to add renderscriptTargetApi to the build.gradle file, like so:

android {
    compileSdkVersion 17
    buildToolsVersion "18.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 16
        renderscriptTargetApi = 16
    }
}

Upvotes: 7

Related Questions