0

I am trying to get a simple renderscript function to take two numnbers, add them and return the result, however I have not managed to find an example project to do that smoothly. I keep getting a weird error when I try to load the file:

ScriptC_myexamplescript myScript;
RenderScript rs = RenderScript.create(this);

I get the error:

Symbol not found: .rs.dtor  on the next line:
myScript = new ScriptC_myexamplescript(rs, getResources(), R.raw.myexamplescript);

My .rs file is just something simple:

#pragma version(1)
#pragma rs java_package_name(com.exercise.<my pacakge name>);

void init(){

}

void root(const float *v_in, float *v_out) {

   const float *data = v_in;
   float *outData = v_out;
   *outData = *data;    

}

Does anyone know what this means, or if there is a simple project I can download for Android ICS and later that does maths, not actual rendering that just works?

(I can get a rendering script file to work, but that isn't what I want. I don't want any graphics in it)

EDIT Today I have tried to make it run, and get the following problem:

Allocation mInAllocation = null;
Allocation mOutAllocation;

float[] A = new float[1];
for (int i = 0; i < 1; i++) {
A[i] = 2;
}



Allocation inFloatPointer = Allocation.createSized(rs, Element.F32(rs), A.length, Allocation.USAGE_SCRIPT);
Allocation outFloatPointer = Allocation.createSized(rs, Element.F32(rs), A.length, Allocation.USAGE_SCRIPT);  
inFloatPointer.copyFrom(A); // copies from an array of floats (random numbers in this test case).
mScript.forEach_root(inFloatPointer, outFloatPointer);            

I get the error message: the method forEach_root is undedifed for type ScriptC_RenderScript There is no function forEach_root in the .java file and even after I clean the project it still is not there.

Is there a simple project I can download with just a maths function I can download?

Thor Russell
  • 119
  • 1
  • 2
  • 12

2 Answers2

1

Are you sure that there is indeed an error here? I believe you are just seeing extra verbose logging information. Can you post the exact logcat (or Java exception trace)? Note that if you actually want to execute your function, you will need to create an input and output allocation and then call "myScript.forEach_root(input, output);" in order to have it execute the root() function on each cell of input/output. When that is done, you can read the results back from the output allocation and use them from Java.

Stephen Hines
  • 2,612
  • 1
  • 13
  • 12
  • Yes there was an error, however today I can't even get it to compile when I put the forEach_root function in as I have noted above. Can you point to a sample project that just works? I think that would be easiest. – Thor Russell Dec 16 '12 at 21:53
  • 1
    You might be seeing that Java missing forEach_root() error because you are targeting an earlier API (which didn't reflect Java versions of forEach). Try using a higher target API (at least ICS). The SDK has a sample HelloCompute benchmark included in it. I can also point you to the AOSP sources (http://source.android.com/source/downloading.html). In AOSP, you can take a look in frameworks/base/tests/RenderScriptTests/ to see a handful of applications that we use for testing. The best example in that directory might be ImageProcessing. – Stephen Hines Dec 17 '12 at 05:21
  • Thanks. Changing the API didn't work however I updated my phone to JB 4.2 and now the hellocompute example works for maths functions. I don't know what was causing the problem but it has gone away now. – Thor Russell Dec 17 '12 at 20:41
  • @StephenHines | bro, you are a life saver :-) – Adil Malik Jun 12 '13 at 15:07
0

Add to the manifest, before <application>, the line

<uses-sdk android:minSdkVersion="14" />

Any value under 14 throws the error you mentioned after ant clean debug

eternauta3k
  • 103
  • 6