Robolectric “Failed to create a android.widget.Button” error

Issue

When I try to run my robolectric tests I receive exception:
java.lang.RuntimeException: Failed to create a android.widget.Button
However if activity doesn’t contains any buttons everything runs ok, but I need buttons 🙂 I use robolectric 2.0-alpha-3-SNAPSHOT, what is more few days ago all tests was run successfully.
Any ideas what can be wrong?

Solution

Finally I’ve solved this problem! My buttons used text color defined like: <color name"TEXT">@android:color/white</color> it seems that robolectric doesn’t have support for @android:color values, so replacing it by <color name"TEXT">#FFF</color> solved my problem

Answered By – Bersh

Leave a Comment