title: Getting different errors for different platforms using Renderscript Support Library
body: <p>I'm having different troubles trying to implement some code written in Renderscript for Android.
  First let me say that all my SDK packages are up-to-dated to the 22.3 version, including the Ecplise ADT and Build-Tools 19.0.0.</p>
  
  <p>My purpose is to implement some high-computational image algorithms on a wide range of Android platforms, possibly starting from API 8. For this, I've set a reference to the <code>renderscript-v8</code> library on my Ecplise project, while targeting the application to API 19.</p>
  
  <p>I have two Android devices to test, the first is an Android 4.3 (API 18), the second comes with Android 2.2 (API 8). I'm experiencing different exceptions when running this piece of code, that calls <a href="http://developer.android.com/reference/android/renderscript/ScriptIntrinsicYuvToRGB.html" rel="nofollow noreferrer">ScriptIntrinsicYuvToRGB</a> (code is partially taken from <a href="https://stackoverflow.com/questions/18435680/executing-scriptintrinsicyuvtorgb">Executing ScriptIntrinsicYuvToRgb</a> question):</p>
  
  <pre><code>/* --------------
     global vars */
  
  private RenderScript rs;
  private ScriptIntrinsicYuvToRGB rs_YUVtoRGB;
  private Allocation rs_YUVtoRGB_in;
  private Allocation rs_YUVtoRGB_out;  
  
  /* --------------
  in constructor... */
  
  this.rs = RenderScript.create(this.getContext());
  this.rs_YUVtoRGB = ScriptIntrinsicYuvToRGB.create(this.rs, Element.U8_4(rs));
  
  Type.Builder tb_in = new Type.Builder(this.rs, Element.createPixel(this.rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));
  tb_in.setX(prevWidth);
  tb_in.setY(prevHeight);
  tb_in.setMipmaps(false);
  tb_in.setYuvFormat(this.camera.getParameters().getPreviewFormat());
  this.rs_YUVtoRGB_in = Allocation.createTyped(this.rs, tb_in.create(), Allocation.USAGE_SCRIPT);
  
  Type.Builder tb_out = new Type.Builder(this.rs, Element.RGBA_8888(this.rs));
  tb_out.setX(prevWidth);
  tb_out.setY(prevHeight);
  tb_out.setMipmaps(false);
  this.rs_YUVtoRGB_out = Allocation.createTyped (this.rs, tb_out.create(), Allocation.USAGE_SCRIPT);
  
  /* --------------
  launching the script... */
  
  // byte[] raw... // a YUV image
  
  this.rs_YUVtoRGB_in.copyFrom(raw);
  this.rs_YUVtoRGB.setInput(this.rs_YUVtoRGB_in);
  this.rs_YUVtoRGB.forEach(this.rs_YUVtoRGB_out);
  
  int[] framePixels = new int[previewSize.width * previewSize.height];
  this.rs_YUVtoRGB_out.copyTo(framePixels);  // final RGB converted image
  </code></pre>
  
  <p>Eclipse manages to compile it (it should mean that the library is well referenced), but...</p>
  
  <p>Android 4.3 fails at : <code>Type.Builder tb_in = new Type.Builder(this.rs, Element.createPixel(this.rs, Element.DataType.UNSIGNED_8, Element.DataKind.PIXEL_YUV));</code> with <code>Unsupported DataKind</code></p>
  
  <pre><code>11-24 11:17:57.685: E/AndroidRuntime(2494): FATAL EXCEPTION: main
  11-24 11:17:57.685: E/AndroidRuntime(2494): android.renderscript.RSIllegalArgumentException: Unsupported DataKind
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.renderscript.Element.createPixel(Element.java:911)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.support.v8.renderscript.ElementThunker.createPixel(ElementThunker.java:224)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.support.v8.renderscript.Element.createPixel(Element.java:832)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at com.lag.appprj.CameraPreview.setupCamera(CameraPreview.java:167)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at com.lag.appprj.CameraPreview.surfaceCreated(CameraPreview.java:86)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.SurfaceView.updateWindow(SurfaceView.java:571)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.SurfaceView.access$000(SurfaceView.java:86)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:833)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
  11-24 11:17:57.685: E/AndroidRuntime(2494):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
  </code></pre>
  
  <p>While on Android 2.2 it fails in the init phase: <code>Error loading RS jni library: java.lang.UnsatisfiedLinkError: Library RSSupport not found</code> </p>
  
  <pre><code>11-24 11:45:45.329: E/AndroidRuntime(2048): FATAL EXCEPTION: main
  11-24 11:45:45.329: E/AndroidRuntime(2048): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lag.appprj/com.lag.appprj.CaptureActivity}: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Library RSSupport not found
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.os.Handler.dispatchMessage(Handler.java:99)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.os.Looper.loop(Looper.java:123)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at java.lang.reflect.Method.invoke(Method.java:521)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at dalvik.system.NativeStart.main(Native Method)
  11-24 11:45:45.329: E/AndroidRuntime(2048): Caused by: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Library RSSupport not found
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.support.v8.renderscript.RenderScript.create(RenderScript.java:945)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.support.v8.renderscript.RenderScript.create(RenderScript.java:982)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.support.v8.renderscript.RenderScript.create(RenderScript.java:968)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at com.lag.appprj.CameraPreview.&lt;init&gt;(CameraPreview.java:80)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at com.lag.appprj.CaptureActivity.onCreate(CaptureActivity.java:34)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  11-24 11:45:45.329: E/AndroidRuntime(2048):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  </code></pre>
  
  <p>Thanks for the help</p>