I know this topic has been discussed but it is a little different here:
- App works fine
- Error is displayed only in unit test
- Theme is Fine (new created sample project)
How to reproduce:
- Create just a new project --> FullScreenActivity Android 4.3
- Create a unit test
-
Run it
public class FullscreenActivityTest extends ActivityUnitTestCase<FullscreenActivity> { public FullscreenActivityTest() { super(FullscreenActivity.class); } public void testStart() { startActivity(new Intent(getInstrumentation() .getTargetContext(), FullscreenActivity.class), null, null); Assert.assertNotNull(getActivity()); }
}
Tested with:
- Nexus 5 Emulator
- Nexus 6P Emulator
Each time the same, app works fine. Unit test fails with:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:124)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.comfylight.foobar.FullscreenActivity.onCreate(FullscreenActivity.java:88)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.test.ActivityUnitTestCase.startActivity(ActivityUnitTestCase.java:163)
Thanks,
Paul
Aucun commentaire:
Enregistrer un commentaire