React-native-blur: [Android] App crashing with `java.lang.NoClassDefFoundError`

Created on 4 Nov 2016  路  5Comments  路  Source: Kureev/react-native-blur

When a component mounts containing a <BlurView/>, the app crashes and I see the following mammoth of an error:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.myTestApp, PID: 2894
                  java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v8/renderscript/RenderScript;
                      at com.fivehundredpx.android.blur.BlurringView.initializeRenderScript(BlurringView.java:98)
                      at com.fivehundredpx.android.blur.BlurringView.<init>(BlurringView.java:37)
                      at com.fivehundredpx.android.blur.BlurringView.<init>(BlurringView.java:26)
                      at com.cmcewen.blurview.BlurViewManager.createViewInstance(BlurViewManager.java:24)
                      at com.cmcewen.blurview.BlurViewManager.createViewInstance(BlurViewManager.java:11)
                      at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:44)
                      at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:211)
                      at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:148)
                      at com.facebook.react.uimanager.UIViewOperationQueue$2.run(UIViewOperationQueue.java:776)
                      at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:829)
                      at com.facebook.react.uimanager.UIViewOperationQueue.access$1500(UIViewOperationQueue.java:44)
                      at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:868)
                      at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
                      at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:131)
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869)
                      at android.view.Choreographer.doCallbacks(Choreographer.java:683)
                      at android.view.Choreographer.doFrame(Choreographer.java:616)
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
                      at android.os.Handler.handleCallback(Handler.java:751)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6077)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v8.renderscript.RenderScript" on path: DexPathList[[dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-support-annotations-24.0.0_07c6617923f08fa2550282db0599a713e491a5c0-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okio-1.9.0_865c34b966a3232857e4e228ff8d64f088265f29-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-ws-3.4.1_81de84de6be95ac4835db6d84e153fd409cb3304-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-urlconnection-3.4.1_cb935f89fd3e1bc1ab9c6b586b6a9950d787374d-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-3.4.1_8c2fbd0ddfe0f24fe26eafd4c37cd2dff463b617-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-library-2.4.0_85085f2497a7cfe4080fe0da765e8b26e353aa9c-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-jsr305-3.0.0_7106bcd665b86ed9b1c06d9f4d215aa7e9f69bea-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-javax.inject-1_c4bdcc1e91611fa283abac4ead29a876d6dff68b-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-jackson-core-2.2.3_b12dcc7f54d2eb1cf0a2a582eca573fe4fb13f2e-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-internal_impl-24.0.0_09ceb63bde671769242c2363b9e612ad92070633-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-infer-annotations-1.5_844c342d51a00bc9632d469a8ccb47366ff833a7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.onesignal-OneSignal-2.6.2_f9214a4acbc9ee802359bbf08e12151b6ad475eb-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-tasks-9.6.1_13a3d76fe10d3f17e95d6a74acd3125fe73a369e-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-location-9.6.1_b3b741ff8f15f10442e40e85da95da564dc44765-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-iid-9.6.1_7648e7bb550afd6ca1754ba978b1c4953749cd27-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-gcm-9.6.1_df6a808afa32e94e5882516be850d06fdbbce75f-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.6.1_01be22a39b90b1c5c17370d9ae70450b46676135-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-base-9.6.1_4ac7ec4236e6969956a677214fc66896f3413fb7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-analytics-impl-9.6.1_4744539881bebb5ed3aa0d1acfee9c6aff6b4550-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-analytics-9.6.1_99b28033e
E/AndroidRuntime: 9c2993820b81a3f68783589bc68b1a3-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.fivehundredpx-blurringview-1.0.0_4294dae8928154fb3aad1d4617e7df72a7c23f79-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.soloader-soloader-0.1.0_18c89d0be6ad813b84ec4840103a0594153e0235-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.react-react-native-0.35.0_fbb7da3bb3bf3da154eb037bbbe6f996ff71bdc1-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.fresco-imagepipeline-okhttp3-0.11.0_cf83a396084db62013cc6ccd206fb8b1b83eb0e6-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.fresco-imagepipeline-base-0.11.0_3729573252f67528deb4c458f54e6b1d0d77383f-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.fresco-imagepipeline-0.11.0_45653dd968af1a8b76dcdb0d9bdcae68ef6e008b-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.fresco-fresco-0.11.0_793cb77d548b8e04a5e041cc4caae31af1bf64a7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.fresco-fbcore-0.11.0_89c847ba4d4baac6619dffc9e41c17bda40e0ab6-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.facebook.fresco-drawee-0.11.0_e5ae5532e52880acbb17739a63eb32bba4ab8ac1-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.android.support-support-v4-24.0.0_e32096654aad095922fe8aea2fe2c3bab5941921-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.android.support-recyclerview-v7-23.0.1_2db247299ed36486e43c0827b533829bbac6b01b-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.0.1_1925a39573a02c2bb61305de18f7b05af799aadb-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-bolts-tasks-1.4.0_46a51ab28f77e3936d22ce31be60cea6f3fe2730-classes.dex"],nativeLibraryDirectories=[/data/app/com.myTestApp-1/lib/x86, /system/fake-libs, /data/app/com.myTestApp-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
                      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                      at com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader.findClass(IncrementalClassLoader.java:90)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                        ... 25 more
D/Error: ERR: exClass=java.lang.ClassNotFoundException
D/Error: ERR: exMsg=Didn't find class "android.support.v8.renderscript.RenderScript" on path: DexPathList[[dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-support-annotations-24.0.0_07c6617923f08fa2550282db0599a713e491a5c0-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okio-1.9.0_865c34b966a3232857e4e228ff8d64f088265f29-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-ws-3.4.1_81de84de6be95ac4835db6d84e153fd409cb3304-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-urlconnection-3.4.1_cb935f89fd3e1bc1ab9c6b586b6a9950d787374d-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-3.4.1_8c2fbd0ddfe0f24fe26eafd4c37cd2dff463b617-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-library-2.4.0_85085f2497a7cfe4080fe0da765e8b26e353aa9c-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-jsr305-3.0.0_7106bcd665b86ed9b1c06d9f4d215aa7e9f69bea-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-javax.inject-1_c4bdcc1e91611fa283abac4ead29a876d6dff68b-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-jackson-core-2.2.3_b12dcc7f54d2eb1cf0a2a582eca573fe4fb13f2e-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-internal_impl-24.0.0_09ceb63bde671769242c2363b9e612ad92070633-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-infer-annotations-1.5_844c342d51a00bc9632d469a8ccb47366ff833a7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.onesignal-OneSignal-2.6.2_f9214a4acbc9ee802359bbf08e12151b6ad475eb-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-tasks-9.6.1_13a3d76fe10d3f17e95d6a74acd3125fe73a369e-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-location-9.6.1_b3b741ff8f15f10442e40e85da95da564dc44765-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-iid-9.6.1_7648e7bb550afd6ca1754ba978b1c4953749cd27-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-gcm-9.6.1_df6a808afa32e94e5882516be850d06fdbbce75f-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.6.1_01be22a39b90b1c5c17370d9ae70450b46676135-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-base-9.6.1_4ac7ec4236e6969956a677214fc66896f3413fb7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-analytics-impl-9.6.1_4744539881bebb5ed3aa0d1acfee9c6aff6b4550-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-com.google.android.gms-play-services-analytics-9.6.1_99b28033e9c2993820b81a3f68783589bc68b1a3-classes.dex", dex file "/data/data/com.idr
D/Error: ERR: file=BaseDexClassLoader.java
D/Error: ERR: class=dalvik.system.BaseDexClassLoader
D/Error: ERR: method=findClass line=56
D/Error: ERR: stack=java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v8/renderscript/RenderScript;
             at com.fivehundredpx.android.blur.BlurringView.initializeRenderScript(BlurringView.java:98)
             at com.fivehundredpx.android.blur.BlurringView.<init>(BlurringView.java:37)
             at com.fivehundredpx.android.blur.BlurringView.<init>(BlurringView.java:26)
             at com.cmcewen.blurview.BlurViewManager.createViewInstance(BlurViewManager.java:24)
             at com.cmcewen.blurview.BlurViewManager.createViewInstance(BlurViewManager.java:11)
             at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:44)
             at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:211)
             at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:148)
             at com.facebook.react.uimanager.UIViewOperationQueue$2.run(UIViewOperationQueue.java:776)
             at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:829)
             at com.facebook.react.uimanager.UIViewOperationQueue.access$1500(UIViewOperationQueue.java:44)
             at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:868)
             at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
             at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:131)
             at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869)
             at android.view.Choreographer.doCallbacks(Choreographer.java:683)
             at android.view.Choreographer.doFrame(Choreographer.java:616)
             at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
             at android.os.Handler.handleCallback(Handler.java:751)
             at android.os.Handler.dispatchMessage(Handler.java:95)
             at android.os.Looper.loop(Looper.java:154)
             at android.app.ActivityThread.main(ActivityThread.java:6077)
             at java.lang.reflect.Method.invoke(Native Method)
             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
          Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v8.renderscript.RenderScript" on path: DexPathList[[dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-support-annotations-24.0.0_07c6617923f08fa2550282db0599a713e491a5c0-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okio-1.9.0_865c34b966a3232857e4e228ff8d64f088265f29-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-ws-3.4.1_81de84de6be95ac4835db6d84e153fd409cb3304-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-urlconnection-3.4.1_cb935f89fd3e1bc1ab9c6b586b6a9950d787374d-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-okhttp-3.4.1_8c2fbd0ddfe0f24fe26eafd4c37cd2dff463b617-classes.dex", dex file "/data/data/com.myTestApp/files/instant-run/dex/slice-library-2.4.0_85085f2497a7cfe4080fe0da765e8b26e353aa9c-classes.dex", dex file "/data/data/com.idr
D/Error: ERR: TOTAL BYTES WRITTEN: 30288
Application terminated.

Most helpful comment

There's not really much more to explain than @JackyAndroid's answer already does, @arhmnsh. Just add the following into your apps build.gradle file:

renderscriptTargetApi 21
renderscriptSupportModeEnabled true

Example:

image

_Note:_ I've just added the necessary lines into another project to show where they need to go. Don't pay any attention to what's not highlighted in the red boxes 馃檭

All 5 comments

Sorry, think this is something with 500px-android-blur, https://github.com/500px/500px-android-blur/issues/15

Also mentioned here by @undef1ned: https://github.com/react-native-community/react-native-blur/pull/59#issuecomment-221401242. Did you find a solution for this?

@breadadams
Can you please post how to use that solution?

There's not really much more to explain than @JackyAndroid's answer already does, @arhmnsh. Just add the following into your apps build.gradle file:

renderscriptTargetApi 21
renderscriptSupportModeEnabled true

Example:

image

_Note:_ I've just added the necessary lines into another project to show where they need to go. Don't pay any attention to what's not highlighted in the red boxes 馃檭

Thanks @breadadams! But after adding those lines, I ran into this issue: https://github.com/react-native-community/react-native-blur/issues/88

Error: duplicate files during packaging of APK /Users/ndbroadbent/code/my_app/android/app/build/outputs/apk/app-armeabi-v7a-debug-unaligned.apk
    Path in archive: lib/armeabi-v7a/libblasV8.so
    Origin 1: /Users/ndbroadbent/code/my_app/android/app/build/intermediates/exploded-aar/com.fivehundredpx/blurringview/1.0.0/jni/armeabi-v7a/libblasV8.so
    Origin 2: /Users/ndbroadbent/Library/Android/sdk/build-tools/23.0.1/renderscript/lib/packaged/armeabi-v7a/libblasV8.so
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'lib/armeabi-v7a/libblasV8.so'
      }
    }

So I finally got it to work after updating the "Android Plugin for Gradle" version in ./android/build.gradle:

        classpath 'com.android.tools.build:gradle:2.2.3'

Then finally I was able to compile and run my app, but then I immediately ran into this issue. Fortunately it wasn't too hard to remove all the child views and just absolutely position the blur view in the background.

At this point, the blur view is still not working, but at least the app is compiling and running, and I think I can figure it out from here.

Anyway, it would be great if some of these instructions could be added to the README.

Was this page helpful?
0 / 5 - 0 ratings