Renderscript broken with AndroidX?

renderscript android
com android renderscript cache
class landroidx renderscript renderscript
react-native androidx
convert to androidx
android support-v4 content contextcompat androidx

Since I've migrated to androidx I can't make Renderscript run. I'm getting following exception:

2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException: Didn't find class "android.support.v8.renderscript.RenderScript" on path: DexPathList[[zip file "/data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/base.apk"],nativeLibraryDirectories=[/data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/lib/arm64, /data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]] 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String) (Runtime.java:-2) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at java.lang.String java.lang.Runtime.doLoad(java.lang.String, java.lang.ClassLoader) (Runtime.java:1099) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at void java.lang.Runtime.loadLibrary0(java.lang.ClassLoader, java.lang.String) (Runtime.java:1014) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at void java.lang.System.loadLibrary(java.lang.String) (System.java:1657) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at androidx.renderscript.RenderScript androidx.renderscript.RenderScript.internalCreate(android.content.Context, int, androidx.renderscript.RenderScript$ContextType, int) (RenderScript.java:1408) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at androidx.renderscript.RenderScript androidx.renderscript.RenderScript.create(android.content.Context, int, androidx.renderscript.RenderScript$ContextType, int) (RenderScript.java:1599) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at androidx.renderscript.RenderScript androidx.renderscript.RenderScript.create(android.content.Context, androidx.renderscript.RenderScript$ContextType, int) (RenderScript.java:1549) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at androidx.renderscript.RenderScript androidx.renderscript.RenderScript.create(android.content.Context, androidx.renderscript.RenderScript$ContextType) (RenderScript.java:1525) 2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at androidx.renderscript.RenderScript androidx.renderscript.RenderScript.create(android.content.Context) (RenderScript.java:1512)

I have usual entries in gradle:

    renderscriptTargetApi 18
    renderscriptSupportModeEnabled true

Anything else I have to change?

I had the same issue, i switched to non support version of renderscript

In project gradle

renderscriptTargetApi 17
renderscriptSupportModeEnabled false

And in the class that use renderscript

import android.renderscript.RenderScript

instead of

import androidx.renderscript.RenderScript

It did the job for me but i don't like this solution, to be completed

I had the same issue, i switched to non support version of renderscript. In project gradle renderscriptTargetApi 17  tested on SONY xperia c4 (android 5.1) and works as expected, fails on general mobile android one (android 7), lg g3, g4 ect – Onur Emrecan Özcan Nov 30 '16 at 21:32 at this time I do not have any different device to test but when I find one I will try and append results – Onur Emrecan Özcan Nov 30 '16 at 21:40

There was an issue with the build tools (the prebuilt librsjni_androidx.so, to be exact), and is now fixed in version 29.0.2.

I've verified this by upgrading compile sdk to API 29 and build tools to 29.0.2.

Edit: This is what I've configured in build.gradle:

    renderscriptTargetApi 18
    renderscriptSupportModeEnabled true

We probably need to add a rule - android.support.v8.renderscript. stackoverflow.com/questions/52781821/renderscript-broken-with-androidx. ChrisK0043. Apparently, this user prefers to keep an air of mystery about them. 2. answers. 8. questions ~238. people reached. 3 Renderscript broken with AndroidX

The marked answer does make it work, but as @Zee mentioned, it seems that the non-support regular renderscript removes 64-bit compatibility. Now I got a warning message from Google Play console about it when trying to publish my app. So I guess if we are still using renderscript, we will have to stay with support version and not migrate to AndroidX for now.

This class provides access to a RenderScript context, which controls to break the connection before the object is permanently discarded. The Renderscript code does the intensive computation and returns the result back to the Android VM. You can find the Renderscript native APIs in the <sdk_root>/platforms/android-11/renderscript directory. The Android system APIs are broken into a few main groups: Core. These classes are used internally by the system for memory allocation.

I was able to solve the problem by changing the version of buildToolsVersion to 29.0.2 and renderscriptTargetApi to 29:

android {
    // ...
    buildToolsVersion '29.0.2'
    defaultConfig {
        // ...
        renderscriptTargetApi 29
        renderscriptSupportModeEnabled true
    }
    // ...
}

The malloc call can be broken up into two parts: the size of the memory being allocated ( sizeof(int) ), along with how many units of that memory  When your Android framework code calls into RenderScript, the call is queued and is executed when possible. This restriction allows the RenderScript system to function without constant interruption and increases efficiency.

in my gradle module file I had:

renderscriptTargetApi 19
renderscriptSupportModeEnabled true

And, I had the following imports before migrating to AndroidX:

import android.support.v8.renderscript.Allocation;
import android.support.v8.renderscript.Element;
import android.support.v8.renderscript.Matrix4f;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.ScriptIntrinsicBlur;
import android.support.v8.renderscript.ScriptIntrinsicColorMatrix;
import android.support.v8.renderscript.ScriptIntrinsicConvolve3x3;

After migrating to AndroidX, just like the documentation says:

I kept the same statements on my gradle module file, but I upgraded to buildToolsVersion 29.0.2 and my compileSdkVersion to 28

I changed the previous imports to the following, and it all works.

import androidx.renderscript.Matrix4f;
import androidx.renderscript.RenderScript;
import androidx.renderscript.Allocation;
import androidx.renderscript.Element;
import androidx.renderscript.ScriptIntrinsicBlur;
import androidx.renderscript.ScriptIntrinsicColorMatrix;
import androidx.renderscript.ScriptIntrinsicConvolve3x3;

The RenderScript runtime will very often split the execution of one kernel across multiple threads. Updating globals should be done with atomic  11-08 02:33:00.537 1818-1818/com.android.launcher D/EGL_emulation: eglMakeCurrent: 0xb858b100: ver 2 0 11-08 02:33:00.627 1135-1135/? I/DEBUG: eax b84790b0 ebx 99f45100 ecx b6b2c920 edx b8521558

Android is deprecating the Support compatibility libraries and replacing them with the new AndroidX libraries. To aid in the migration of Android  Preview and recover data from broken Android phone to PC. Here Are The Details: Step 1. Connect your broken Android phone to a PC. After installing Broken Android Data Recovery, select the "Broken Android Data Extraction" tool and connect your broken phone to a PC via a USB cable. Step 2. Choose proper mode for data recovery.

Google released RenderScript to take high-performance computation algorithms on Android to the next level. As device hardware capabilities advance,  Back up your Android data on computer and restore it selectively or entirely. User Guide: How to Use FonePaw Broken Android Data Extraction. Launch FonePaw for Android. Move in Broken Android Data Extraction. Connect phone to scan or fix. Preview and recover what you need. Get Complete Guide Here. What our customers have to say.

toString(), mSrcImage, mDstImage, radius); break; } mDstImageView.invalidate(); } } Time for action – running RenderScript Blur intrinsic Let's create the native  Screem-broken Android phone is one of the most common cases we can see among Android user. In such a case, part of the screen doesn't repond to finger touches, so you can't do backup operation on the phone. However, you can recover the data from the phone with a USB cable. Step 1: Carefully, attach your USB data cable with your Android

Comments
  • I'm also having issues with renderscript... it crashes my app with a fatal signal11 pre API21
  • This solved it for me as well, it was crashing on API 21 before. renderscriptTargetApi can be at least the same as your minSdkVersion though I think.
  • Strange! Seems only broken with AndroidX. Works like a charm with the legacy support library
  • What do you miss out on by turning renderscriptSupportMode off?
  • Guys, I've kinda found a problem with this. It seems that changing from the support libraries (android.support.v8.renderscript) to the regular renderscript libraries (android.renderscript.RenderScript), removes 64-bit compatibility. This means your app will no longer be supported by 1 Aug on the playstore for 64 bit phones. Has anyone found a solution for this???
  • @Zee it seems that you need bump your renderscriptTargetApi to 21 or later to get 64-bit support - developer.android.com/distribute/best-practices/develop/…
  • what is your default config like? are you using renderscriptTargetApi 21 renderscriptSupportModeEnabled true?
  • @dtunctuncer hey I've edited the answer to include my configs in build.gradle: renderscriptTargetApi 18 renderscriptSupportModeEnabled true
  • thanks man I will try it I hope it won't introduce new crashes :)
  • I published an app (closed alpha) in Google Play with RenderScript without support mode and I got no warnings. But I did notice the filesize is about 2MB smaller, and the Native platforms in Google Play are listed as None. With support mode enabled, there were 4 (arm64-v8a, armeabi-v7a, x86, x86_64).