OSDN Git Service

Improve error reporting for buggy View subclasses
authorAdam Powell <adamp@google.com>
Thu, 16 Apr 2015 21:54:10 +0000 (14:54 -0700)
committerAdam Powell <adamp@google.com>
Thu, 16 Apr 2015 21:54:10 +0000 (14:54 -0700)
When a view doesn't call setMeasuredDimension, note the view ID
and class name as part of the exception message.

Bug 18037248

Change-Id: I1c5ed823378ad92a067801dc8c3be31b07c6f463

core/java/android/view/View.java

index 25fa349..fa40e5f 100644 (file)
@@ -18173,7 +18173,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
             // flag not set, setMeasuredDimension() was not invoked, we raise
             // an exception to warn the developer
             if ((mPrivateFlags & PFLAG_MEASURED_DIMENSION_SET) != PFLAG_MEASURED_DIMENSION_SET) {
-                throw new IllegalStateException("onMeasure() did not set the"
+                throw new IllegalStateException("View with id " + getId() + ": "
+                        + getClass().getName() + "#onMeasure() did not set the"
                         + " measured dimension by calling"
                         + " setMeasuredDimension()");
             }