2014-04-29 4 views
7

Ich verwende Robolectric, und ich erhalte den folgenden Fehler beim Erstellen einer Aktivität. Ich bin mit dem 2,3-Snapshot - androidTestCompile('org.robolectric:robolectric:2.3-SNAPSHOT')Robolectric - screen_action_bar.xml Zeile # -1 (Sorry, noch nicht implementiert): Fehler beim Aufblasen der Klasse <unknown>

android.view.InflateException: XML file jar:/Users/user/.m2/repository/org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.jar!/res/layout/screen_action_bar.xml line #-1 (sorry, not yet implemented): Error inflating class <unknown> 
    at android.view.LayoutInflater.createView(LayoutInflater.java:620) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2823) 
    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2886) 
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:263) 
    at android.app.Activity.setContentView(Activity.java:1895) 
    at com.company.app.activities.loginjoin.LoginActivity.onCreate(LoginActivity.java:49) 
    at android.app.Activity.performCreate(Activity.java:5133) 
    at org.fest.reflect.method.Invoker.invoke(Invoker.java:112) 
    at org.robolectric.util.ActivityController$1.run(ActivityController.java:147) 
    at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:265) 
    at org.robolectric.util.ActivityController.create(ActivityController.java:144) 
    at org.robolectric.util.ActivityController.create(ActivityController.java:154) 
    at com.company.app.activities.loginjoin.LoginActivityTest.setup(LoginActivityTest.java:21) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250) 
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69) 
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) 
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355) 
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:744) 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_createView(LayoutInflater.java:594) 
    at android.view.LayoutInflater.createView(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_createViewFromTag(LayoutInflater.java:696) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java) 
    at android.view.LayoutInflater.$$robo$$LayoutInflater_1d1f_inflate(LayoutInflater.java:353) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java) 
    at com.android.internal.policy.impl.PhoneWindow.$$robo$$PhoneWindow_1a87_generateLayout(PhoneWindow.java:2823) 
    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java) 
    at com.android.internal.policy.impl.PhoneWindow.$$robo$$PhoneWindow_1a87_installDecor(PhoneWindow.java:2886) 
    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java) 
    at com.android.internal.policy.impl.PhoneWindow.$$robo$$PhoneWindow_1a87_setContentView(PhoneWindow.java:263) 
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java) 
    at android.app.Activity.$$robo$$Activity_c57b_setContentView(Activity.java:1895) 
    at android.app.Activity.setContentView(Activity.java) 
    at com.company.app.activities.loginjoin.LoginActivity.onCreate(LoginActivity.java:49) 
    at android.app.Activity.$$robo$$Activity_c57b_performCreate(Activity.java:5133) 
    at android.app.Activity.performCreate(Activity.java) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.fest.reflect.method.Invoker.invoke(Invoker.java:112) 
    at org.robolectric.util.ActivityController$1.run(ActivityController.java:147) 
    at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:265) 
    at org.robolectric.util.ActivityController.create(ActivityController.java:144) 
    at org.robolectric.util.ActivityController.create(ActivityController.java:154) 
    at com.company.app.activities.loginjoin.LoginActivityTest.setup(LoginActivityTest.java:21) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250) 
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69) 
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) 
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    ... 7 more 
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x0 a=765015 r=0x106000d} 
    at android.content.res.Resources.loadDrawable(Resources.java:2063) 
    at org.fest.reflect.method.Invoker.invoke(Invoker.java:112) 
    at org.robolectric.shadows.ShadowResources.loadDrawable(ShadowResources.java:504) 
    at android.content.res.Resources.loadDrawable(Resources.java) 
    at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
    at com.android.internal.widget.ActionBarView.__constructor__(ActionBarView.java:206) 
    at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:177) 
    at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
    at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2823) 
    at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2886) 
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:263) 
    at android.app.Activity.setContentView(Activity.java:1895) 
    at com.company.app.activities.loginjoin.LoginActivity.onCreate(LoginActivity.java:49) 
    at android.app.Activity.performCreate(Activity.java:5133) 
    at org.fest.reflect.method.Invoker.invoke(Invoker.java:112) 
    at org.robolectric.util.ActivityController$1.run(ActivityController.java:147) 
    at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:265) 
    at org.robolectric.util.ActivityController.create(ActivityController.java:144) 
    at org.robolectric.util.ActivityController.create(ActivityController.java:154) 
    at com.company.app.activities.loginjoin.LoginActivityTest.setup(LoginActivityTest.java:21) 
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) 
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) 
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) 
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250) 
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) 
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) 
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) 
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) 
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) 
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) 
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177) 
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49) 
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69) 
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) 
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105) 

Ich sehe die github issue offen ist, aber es ist angeblich ein Windows-Problem. Ich laufe auf einem Mac. Ich öffnete eine separate issue.

Mein Test ist wie folgt. Es geschieht zu jeder Zeit ich die Aktivität Generation create() Methode verwenden:

@Config(emulateSdk = 18) 
public class LoginActivityTest extends BaseRobolectricTest { 

    private LoginActivity activity; 

    @Before 
    public void setup() { 
     super.setup(); 
     activity = Robolectric.buildActivity(LoginActivity.class).create().get(); 
    } 
} 

Antwort

0

EDIT (New Response):

Die Frage zu einem Thema verfolgt wurde, als eine Farbe wie die android:icon in den ActionBar Einstellung. Sehen Sie sich den Thread auf github - https://github.com/robolectric/robolectric/issues/1053 für meine Abhilfe an.


Old Antwort:

Ich konnte das Problem beheben, indem

<item name="android:windowNoTitle">true</item> 

zu meinem Thema Datei hinzufügen. Dies entfernt jedoch den ActionBar-Titel ... was ich nicht möchte. Ich vermute, es ist ein Problem mit dem Styling der ActionBar. Ich werde mit meinen Ergebnissen berichten.

Verwandte Themen