0

I wanted to use RenderScript from the SupportLibrary to create a blur effekt.

For this I've found the solution from here https://stackoverflow.com/a/14988991/408780

final RenderScript rs;
rs = RenderScript.create( myAndroidContext );
final Allocation input = Allocation.createFromBitmap( rs, photo, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT );
final Allocation output = Allocation.createTyped( rs, input.getType() );
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create( rs, Element.U8_4( rs ) );
script.setRadius( myBlurRadius /* e.g. 3.f */ );
script.setInput( input );
script.forEach( output );
output.copyTo( photo );

The problem is, that rs = RenderScript.create(myAndroidContext) causes java.lang.NoClassDefFoundError and I have no idea, what is going wrong.

According to https://developer.android.com/reference/android/support/v8/renderscript/ScriptIntrinsicBlur.html ScriptIntrinsicBlur was added in the version 23.

So I just added to the app gradle following lines:

android {
...
    defaultConfig {
        ...
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
    }
... 
}

I also tried with renderscriptTargetApi 21 as described below https://github.com/react-native-community/react-native-blur/issues/110#issuecomment-272956182

But still no success. Any suggestions?

Maybe some additional infos:

minSdk = 14, targetSdk = 19, compileSdk = 25

Thank you in advance.

Community
  • 1
  • 1
Tima
  • 12,765
  • 23
  • 82
  • 125

1 Answers1

0

What is the build-tools version and gradle-plugin version you are using? Additional error messages would be helpful.

The code looks fine. The problem might be related to proguard configuration. Could you add the following:

-dontwarn android.support.v8.renderscript.*
-keepclassmembers class android.support.v8.renderscript.RenderScript {
  native *** rsn*(...);
  native *** n*(...);
}
Miao Wang
  • 1,120
  • 9
  • 12
  • Sorry for late answer. But ... still the same, build-tools version 25.0.2, gradle-plugin version 2.1.2 – Tima Jul 03 '17 at 11:25