1

I'm writing a test for a support.Fragment, but I keep getting the following exception:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

Exception is thrown when I try to start the fragment (During activity creation):

@RunWith(RobolectricTestRunner.class)
public class AuthFragmentTest extends TestCase {   

    private SupportFragment fragment;

    @Before
    public void setUp() throws Exception {
        fragment = new SupportFragment();

        FragmentTestUtil.startFragment(fragment, SupportFragmentActivity.class);
    }
}

This is the API level Im using.

<uses-sdk
    android:minSdkVersion="10"
    android:targetSdkVersion="19" />

Also, Robolectric is configured to use the same Manifest as the application with /src/test/resources/org.robolectric.Config.properties

My application runs with no problems, support libraries are correctly setup, it's just the test that I can't seem to get right.

Chepech
  • 5,258
  • 4
  • 47
  • 70

1 Answers1

1

For someone who comes across this question, a potential solution can be found - here

The theme you provide must be a child of Theme.MaterialComponents

DaveNbits
  • 131
  • 1
  • 8