Loading of ScriptC script failed - android render script
<p>This issue has been discussed several times, yet I cant get this to work. I tried build tools v23, that did not even compile, so I moved to 21 version which compiled the script code. ScriptC_rotator class is now generated in app\build\generated\source\rs\debug\com\models. However, now I get the run time 'Loading of ScriptC script'. Don't know how to resolve this.</p>

<pre><code>  public Bitmap rotate(Bitmap bitmap) {
       Bitmap target = null;
       try {

           RenderScript rs = RenderScript.create(activity);
           ScriptC_rotator script = new ScriptC_rotator(rs); // this is where the error occur. 
           script.set_inWidth(bitmap.getWidth());
           script.set_inHeight(bitmap.getHeight());
           Allocation sourceAllocation = Allocation.createFromBitmap(rs, bitmap,
                   Allocation.MipmapControl.MIPMAP_NONE,
                   Allocation.USAGE_SCRIPT);
           bitmap.recycle();
           script.set_inImage(sourceAllocation);

           int targetHeight = bitmap.getWidth();
           int targetWidth = bitmap.getHeight();
           Bitmap.Config config = bitmap.getConfig();
           target = Bitmap.createBitmap(targetWidth, targetHeight, config);
           final Allocation targetAllocation = Allocation.createFromBitmap(rs, target,
                   Allocation.MipmapControl.MIPMAP_NONE,
                   Allocation.USAGE_SCRIPT);
           script.forEach_rotate_90_clockwise(targetAllocation, targetAllocation);
           targetAllocation.copyTo(target);
           rs.destroy();
       }
       catch(Exception e){

       }
        return target;
    }
</code></pre>

<p><strong>Error:</strong> 
android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed.</p>

<p><strong>Gradle:</strong> </p>

<pre><code> compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 21
        multiDexEnabled true
        renderscriptTargetApi 17
        renderscriptSupportModeEnabled true
        ndk {
            moduleName "JniBitmapOperationsLibrary"
            ldLibs "log",  "jnigraphics"
            //optional: filter abis to compile for: abiFilters "x86", "armeabi-v7a"
            //otherwise it will compile for all abis: "armeabi", "armeabi-v7a", "x86", and "mips"
        }
    }
</code></pre>

<p><strong>Script and generated code</strong> </p>

<pre><code>#pragma version(1)
#pragma rs_fp_relaxed
#pragma rs java_package_name(com.models)

rs_allocation inImage;
int inWidth;
int inHeight;

uchar4 __attribute__ ((kernel)) rotate_90_clockwise (uchar4 in, uint32_t x, uint32_t y) {
    uint32_t inX  = inWidth - 1 - y;
    uint32_t inY = x;
    const uchar4 *out = rsGetElementAt(inImage, inX, inY);
    return *out;
}

uchar4 __attribute__ ((kernel)) rotate_270_clockwise (uchar4 in, uint32_t x, uint32_t y) {
    uint32_t inX = y;
    uint32_t inY = inHeight - 1 - x;

    const uchar4 *out = rsGetElementAt(inImage, inX, inY);
    return *out;
}


/*
 * Copyright (C) 2011-2014 The Android Open Source Project
 * Licensed under the Apache License, Version 2.0 (the "License");
/*
 * This file is auto-generated. DO NOT MODIFY!
 * The source Renderscript file: C:\\Users\\AndroidstudioProjects\\app\\src\\main\\rs\\rotator.rs
 */

package com.models;

import android.support.v8.renderscript.*;
import android.content.res.Resources;

/**
 * @hide
 */
public class ScriptC_rotator extends ScriptC {
    private static final String __rs_resource_name = "rotator";
    // Constructor
    public  ScriptC_rotator(RenderScript rs) {
        this(rs,
             rs.getApplicationContext().getResources(),
             rs.getApplicationContext().getResources().getIdentifier(
                 __rs_resource_name, "raw",
                 rs.getApplicationContext().getPackageName()));
    }

    public  ScriptC_rotator(RenderScript rs, Resources resources, int id) {
        super(rs, resources, id);
        __ALLOCATION = Element.ALLOCATION(rs);
        __I32 = Element.I32(rs);
        __U8_4 = Element.U8_4(rs);
    }

    private Element __ALLOCATION;
    private Element __I32;
    private Element __U8_4;
    private FieldPacker __rs_fp_ALLOCATION;
    private FieldPacker __rs_fp_I32;
    private final static int mExportVarIdx_inImage = 0;
    private Allocation mExportVar_inImage;
    public synchronized void set_inImage(Allocation v) {
        setVar(mExportVarIdx_inImage, v);
        mExportVar_inImage = v;
    }

    public Allocation get_inImage() {
        return mExportVar_inImage;
    }

    public Script.FieldID getFieldID_inImage() {
        return createFieldID(mExportVarIdx_inImage, null);
    }

    private final static int mExportVarIdx_inWidth = 1;
    private int mExportVar_inWidth;
    public synchronized void set_inWidth(int v) {
        setVar(mExportVarIdx_inWidth, v);
        mExportVar_inWidth = v;
    }

    public int get_inWidth() {
        return mExportVar_inWidth;
    }

    public Script.FieldID getFieldID_inWidth() {
        return createFieldID(mExportVarIdx_inWidth, null);
    }

    private final static int mExportVarIdx_inHeight = 2;
    private int mExportVar_inHeight;
    public synchronized void set_inHeight(int v) {
        setVar(mExportVarIdx_inHeight, v);
        mExportVar_inHeight = v;
    }

    public int get_inHeight() {
        return mExportVar_inHeight;
    }

    public Script.FieldID getFieldID_inHeight() {
        return createFieldID(mExportVarIdx_inHeight, null);
    }

    //private final static int mExportForEachIdx_root = 0;
    private final static int mExportForEachIdx_rotate_90_clockwise = 1;
    public Script.KernelID getKernelID_rotate_90_clockwise() {
        return createKernelID(mExportForEachIdx_rotate_90_clockwise, 59, null, null);
    }

    public void forEach_rotate_90_clockwise(Allocation ain, Allocation aout) {
        forEach_rotate_90_clockwise(ain, aout, null);
    }

    public void forEach_rotate_90_clockwise(Allocation ain, Allocation aout, Script.LaunchOptions sc) {
        // check ain
        if (!ain.getType().getElement().isCompatible(__U8_4)) {
            throw new RSRuntimeException("Type mismatch with U8_4!");
        }
        // check aout
        if (!aout.getType().getElement().isCompatible(__U8_4)) {
            throw new RSRuntimeException("Type mismatch with U8_4!");
        }
        Type t0, t1;        // Verify dimensions
        t0 = ain.getType();
        t1 = aout.getType();
        if ((t0.getCount() != t1.getCount()) ||
            (t0.getX() != t1.getX()) ||
            (t0.getY() != t1.getY()) ||
            (t0.getZ() != t1.getZ()) ||
            (t0.hasFaces()   != t1.hasFaces()) ||
            (t0.hasMipmaps() != t1.hasMipmaps())) {
            throw new RSRuntimeException("Dimension mismatch between parameters ain and aout!");
        }

        forEach(mExportForEachIdx_rotate_90_clockwise, ain, aout, null, sc);
    }

    private final static int mExportForEachIdx_rotate_270_clockwise = 2;
    public Script.KernelID getKernelID_rotate_270_clockwise() {
        return createKernelID(mExportForEachIdx_rotate_270_clockwise, 59, null, null);
    }

    public void forEach_rotate_270_clockwise(Allocation ain, Allocation aout) {
        forEach_rotate_270_clockwise(ain, aout, null);
    }

    public void forEach_rotate_270_clockwise(Allocation ain, Allocation aout, Script.LaunchOptions sc) {
        // check ain
        if (!ain.getType().getElement().isCompatible(__U8_4)) {
            throw new RSRuntimeException("Type mismatch with U8_4!");
        }
        // check aout
        if (!aout.getType().getElement().isCompatible(__U8_4)) {
            throw new RSRuntimeException("Type mismatch with U8_4!");
        }
        Type t0, t1;        // Verify dimensions
        t0 = ain.getType();
        t1 = aout.getType();
        if ((t0.getCount() != t1.getCount()) ||
            (t0.getX() != t1.getX()) ||
            (t0.getY() != t1.getY()) ||
            (t0.getZ() != t1.getZ()) ||
            (t0.hasFaces()   != t1.hasFaces()) ||
            (t0.hasMipmaps() != t1.hasMipmaps())) {
            throw new RSRuntimeException("Dimension mismatch between parameters ain and aout!");
        }

        forEach(mExportForEachIdx_rotate_270_clockwise, ain, aout, null, sc);
    }

}
</code></pre>