Using renderscript v8 support mode to build one jar

0

I have already add the project to the github: https://github.com/akbarxie/testRenderScriptSupportModel

In our project we want to using renderscript support mode to create one android SDK,and this sdk need to support for android 4.0.We use support “android.support.v8.renderscript” . After we convet it to jar module,when I run it on android 4.0,we get the runing time error like this,

Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0

at android.content.res.Resources.getValue(Resources.java:1048)

at android.content.res.Resources.openRawResource(Resources.java:967)

at android.content.res.Resources.openRawResource(Resources.java:949)

at android.support.v8.renderscript.ScriptC.internalCreate(ScriptC.java:91)

at android.support.v8.renderscript.ScriptC.<init>(ScriptC.java:59)

at albin.imperialvision.com.testsr.ScriptC_merge4Images.<init>(ScriptC_merge4Images.java:42)

at albin.imperialvision.com.testsr.ScriptC_merge4Images.<init>(ScriptC_merge4Images.java:34)

at albin.imperialvision.com.testsr.TestScriptC.<init>(TestScriptC.java:16)

at albin.imperialvision.com.testrenderscriptsupport.MainActivity.onCreate(MainActivity.java:29)

at android.app.Activity.performCreate(Activity.java:5143)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 

at android.app.ActivityThread.access$700(ActivityThread.java:131) 

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228) 

at android.os.Handler.dispatchMessage(Handler.java:99) 

at android.os.Looper.loop(Looper.java:137) 

at android.app.ActivityThread.main(ActivityThread.java:4866) 

at java.lang.reflect.Method.invokeNative(Native Method) 

at java.lang.reflect.Method.invoke(Method.java:511) 

 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 

at dalvik.system.NativeStart.main(Native Method) 
    10-31 11:09:32.480 19402-19429/albin.imperialvision.com.testrenderscriptsupport A/libc: Fatal signal 11 (SIGSEGV) at 0x00000010 (code=1),
thread 19429 (erscriptsupport)

for java part TestScriptC.java:

import android.content.Context;
import android.support.v8.renderscript.RenderScript;

/**
 * Created by kevin on 17-10-30.
 */

public class TestScriptC {
    public TestScriptC(Context context)
    {
        ScriptC_merge4Images merge4Images;
        merge4Images=new ScriptC_merge4Images(RenderScript.create(context));
    }

}

and for renderscript merge4Images.rs:

#pragma version(1)
#pragma rs_fp_relaxed
#pragma rs java_package_name(albin.imperialvision.com.testsr)

rs_allocation a_Blob;
rs_allocation b_Blob;
rs_allocation c_Blob;
rs_allocation d_Blob;


uint aoutHeight_dstHPad;
uint aoutWidth_dstWPad;
uint RightOffset_dstWPad;
uint coutWidth_dstWPad;
uint BottomOffset_dstHPad;




void root(uchar4 * out,uint x,uint y)
{

    if(y<aoutHeight_dstHPad)
    {
       *out = ( (x<aoutWidth_dstWPad) ?  rsGetElementAt_uchar4(a_Blob,x,y) : rsGetElementAt_uchar4(b_Blob,x-RightOffset_dstWPad,y) );
    }
    else
    {
       *out = ( (x<coutWidth_dstWPad) ?  rsGetElementAt_uchar4(c_Blob,x,y-BottomOffset_dstHPad) : rsGetElementAt_uchar4(d_Blob,x-RightOffset_dstWPad,y-BottomOffset_dstHPad) );
    }


}

I have test it if we just add the code to project,the program runs ok,but when add it as jar,it got the error. As the error indicate,the error may occured here:

 public  ScriptC_merge4Images(RenderScript rs) {
        this(rs, //  (ScriptC_merge4Images.java:34)
             rs.getApplicationContext().getResources(),
             rs.getApplicationContext().getResources().getIdentifier(
                 __rs_resource_name, "raw",
                 rs.getApplicationContext().getPackageName())//the wrong id from here 
             );
    }

    public  ScriptC_merge4Images(RenderScript rs, Resources resources, int id) {
        super(rs, resources, id);//get wrong id here  (ScriptC_merge4Images.java:42)
        __ALLOCATION = Element.ALLOCATION(rs);
        __U32 = Element.U32(rs);
        __U8_4 = Element.U8_4(rs);
    }
android
renderscript
asked on Stack Overflow Oct 31, 2017 by Albin Xie • edited Oct 31, 2017 by Albin Xie

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0