Robolectric 3.0中使用自定义地图片段时出现InflateException问题

8

我看到很多关于这个问题的话题,例如这个答案涉及SNAPSHOT版本。

这还有必要吗?因为当我尝试设置我的活动时,我会得到:

    android.view.InflateException: XML file /Users/billey_b/android/android/app/build/intermediates/res/merged/targetARTVm/debug/layout/activity_preorder.xml line #-1 (sorry, not yet implemented): Error inflating class fragment
android.view.InflateException: XML file build/intermediates/res/merged/targetARTVm/debug/layout/activity_preorder.xml line #-1 (sorry, not yet implemented): Error inflating class fragment
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
    at com.heetch.activities.PreOrderActivity.onCreate(PreOrderActivity.java:72)
    at android.app.Activity.performCreate(Activity.java:5933)
    at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
    at org.robolectric.util.ActivityController$1.run(ActivityController.java:122)
    at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:304)
    at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:45)
    at org.robolectric.util.ActivityController.create(ActivityController.java:118)
    at org.robolectric.util.ActivityController.create(ActivityController.java:129)
    at org.robolectric.util.ActivityController.setup(ActivityController.java:210)
    at org.robolectric.Robolectric.setupActivity(Robolectric.java:46)
    at com.heetch.flow.preorder.PreOrderSequencesFlowTest.testPreorderFlow(PreOrderSequencesFlowTest.java:40)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:251)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
Caused by: java.lang.NullPointerException
    at com.google.android.gms.maps.internal.zzy.zzaR(Unknown Source)
    at com.google.android.gms.maps.internal.zzy.zzaP(Unknown Source)
    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment$zzb.zzzh(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment$zzb.setActivity(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment$zzb.zza(Unknown Source)
    at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
    at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2169)
    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
    at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(AppCompatDelegateImplV7.java:842)
    at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(AppCompatDelegateImplV11.java:34)
    at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:830)
    at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
    ... 38 more

在XML中,涉及的片段声明如下:
          <fragment
            android:id="@+id/map"
            android:tag="mapfragment"
            class="com.me.widget.CustomSupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

CustomMapFragment扩展了SupportMapFragment

以及我的依赖:

testCompile 'org.robolectric:robolectric:3.0'
testCompile "org.robolectric:shadows-play-services:3.0"
testCompile "org.robolectric:shadows-multidex:3.0"
testCompile 'org.robolectric:shadows-maps:3.0'
testCompile "org.robolectric:shadows-support-v4:3.0"

那么我错过了什么?
1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接