react-native: Fatal Exception: java.lang.NoClassDefFoundError: android/graphics/Outline

Info:

  • ReactNative: 0.30
  • Platform: Android
  • Device: Nexus 5
  • Android OS: 4.4.2
  • Rooted: true

Problem:

The problem, as I see it, is that android.graphics.Outline was introduced in Lollipop 5.0 and it is used in ReactViewBackgroundDrawable.java as an import and as a method parameter. So OSs less than this will crash when this is hit.

StackTrace:

Fatal Exception: java.lang.NoClassDefFoundError: android/graphics/Outline
       at java.lang.Class.getDeclaredMethods(Class.java)
       at java.lang.Class.getDeclaredMethods(Class.java:656)
       at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960)
       at android.view.ViewDebug.exportMethods(ViewDebug.java:1047)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997)
       at android.view.ViewDebug.exportFields(ViewDebug.java:1175)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:996)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983)
       at android.view.ViewDebug.dumpView(ViewDebug.java:900)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:855)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dump(ViewDebug.java:793)
       at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416)
       at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258)
       at android.view.IWindow$Stub.onTransact(IWindow.java:65)
       at android.os.Binder.execTransact(Binder.java:404)
       at dalvik.system.NativeStart.run(NativeStart.java)
Caused by java.lang.ClassNotFoundException: Didn't find class "android.graphics.Outline" on path: DexPathList[[zip file "/data/app/com.curse.highwind-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.curse.highwind-1, /vendor/lib, /system/lib]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
       at java.lang.Class.getDeclaredMethods(Class.java)
       at java.lang.Class.getDeclaredMethods(Class.java:656)
       at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960)
       at android.view.ViewDebug.exportMethods(ViewDebug.java:1047)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997)
       at android.view.ViewDebug.exportFields(ViewDebug.java:1175)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:996)
       at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983)
       at android.view.ViewDebug.dumpView(ViewDebug.java:900)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:855)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
       at android.view.ViewDebug.dump(ViewDebug.java:793)
       at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416)
       at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258)
       at android.view.IWindow$Stub.onTransact(IWindow.java:65)
       at android.os.Binder.execTransact(Binder.java:404)
       at dalvik.system.NativeStart.run(NativeStart.java)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 15 (4 by maintainers)

Most upvoted comments

If you set multiDexEnabled true in android/app/build.gradle, modify MainApplication.java by the following

import android.support.multidex.MultiDexApplication;
public class MainApplication extends MultiDexApplication implements ReactApplication

So it seems everyone sees this on a rooted Nexus 5 4.4.2 (API level 19), one that has ViewDebug enabled. That seems like quite the awful coincidence, but whomever that rogue user is using all our different apps, I’m not too worried about them anymore. 😃

My guess is that there is some automated system out there running all Android apps in their rooted debug environment, unintentionally breaking when attempting to run our React Native apps. Perhaps it’s used for rendering screenshots, for interacting with apps-in-the-cloud, or maybe a grad student research project, or who knows what else.

I’m confused…ReactViewBackgroundDrawable imports and uses android.graphics.Outline. But android.graphics.Outline was only added in API level 21 (ie 5.0), according to: https://developer.android.com/reference/android/graphics/Outline.html

So in theory, this should break React Native on 4.x devices due to that import. However, the code was added back in RN 0.22, so I assume the code has been fine on Android: https://github.com/facebook/react-native/commit/b65f1f223488b52963f80a67bb41956103263d27

My crash is coming from a user who is running a root-ed Nexus 5 on 4.4.2. (Curious who your users are who also see this…) I’m guessing there might be some special debug mode enabled that is triggering ViewDebug.dispatchCommand calling DUMP, which is then triggering a full dump of all fields/properties (and triggering the load of Outline)

So my questions: Is there a way to blacklist certain methods/classes (such as Outline) from ViewDebug’s dump, to let it run without crashing?

@lacker Wondering why this issue was closed. I’m getting the same crashes from a SM-G900R7, which is a Samsung Galaxy S5 running 4.4.2, which seems to be different from the device that has been listed above (all Nexus 5 running 4.4.2) so this is probably not limited to a certain device. It could be happening only on Android 4.4.2, but it’s still an issue.

Got crash report on Galaxy S5 (4.4.2) . RN 0.52

Still seeing this on 0.34