Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

So file error on multiple devices #3

Open
rohankandwal opened this issue Mar 12, 2019 · 6 comments
Open

So file error on multiple devices #3

rohankandwal opened this issue Mar 12, 2019 · 6 comments

Comments

@rohankandwal
Copy link

Caused by androidx.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/xxxx-1/lib/arm64/librsjni_androidx.so" Support lib API: 2301
at androidx.renderscript.RenderScript.internalCreate(RenderScript.java:1414)
at androidx.renderscript.RenderScript.create(RenderScript.java:1599)
at androidx.renderscript.RenderScript.create(RenderScript.java:1549)
at androidx.renderscript.RenderScript.create(RenderScript.java:1525)
at androidx.renderscript.RenderScript.create(RenderScript.java:1512)
at com.jackandphantom.blurimage.BlurImage.blur(BlurImage.java:53)
at com.jackandphantom.blurimage.BlurImage$AsyncBlurImage.doInBackground(BlurImage.java:155)
at com.jackandphantom.blurimage.BlurImage$AsyncBlurImage.doInBackground(BlurImage.java:146)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

@sparrow007
Copy link
Owner

@rohankandwal thanks for Log cat i will resolve it as soon as possible

@sparrow007
Copy link
Owner

@rohankandwal if you want to take this issue you can feel free to contribute.

@rohankandwal
Copy link
Author

@sparrow007 Not very expert on RenderScript, but create and used the following class, which never caused any crashes so far. The app is already live, still didn't get one.

public class BlurBuilder {
    private static final float BITMAP_SCALE = 0.2f;
    private static final float BLUR_RADIUS = 7.5f;

    public static Bitmap blur(View v) {
        return blur(v.getContext(), getScreenshot(v));
    }

    public static Bitmap blur(Context ctx, Bitmap image) {
        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

         Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(ctx);
        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);

        return outputBitmap;
    }

    private static Bitmap getScreenshot(View v) {
        Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(b);
        v.draw(c);
        return b;
    }
}

Let me know if above code makes any sense to you and it can be of some help.

@Jorgesys
Copy link

@rohankandwal apparently the error ocurrs in this line:

RenderScript rs = RenderScript.create(ctx);

but only in apps that are already using "androidx" and with OS 5.0 and 5.1 apparently.

@fmaxx
Copy link

fmaxx commented Sep 17, 2019

I've fixed up that issue to change:
buildToolsVersion '29.0.2' (was 28.0.3)

@rex50
Copy link

rex50 commented Jun 27, 2021

I was getting same error in only release builds.

I've added below lines in my Proguard file and the issue got solved

#For RenderScript
-keepclasseswithmembernames class * {
native <methods>;
}
-keep class androidx.renderscript.** { *; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants