gpt4 book ai didi

android - Robolectric Resources$NotFoundException :drawable\abc_ic_ab_back_material. 来自可绘制资源 ID 的 xml

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:14:37 27 4
gpt4 key购买 nike

当我尝试运行时:

Robolectric.setupActivity(MainActivity.class).getSupportFragmentManager()
.beginTransaction().add(mapFragment, "" + NavigationCtrl.FRAG_MAP).commit();

Robolectric 抛出错误:

android.content.res.Resources$NotFoundException: File build\intermediates\res\merged\dev\drawable\abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
at android.content.res.Resources.loadDrawable(Resources.java:2091)
at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
at org.robolectric.internal.Shadow.directlyOn(Shadow.java:57)
at org.robolectric.shadows.ShadowResources.loadDrawable(ShadowResources.java:225)
at android.content.res.Resources.loadDrawable(Resources.java)
at android.content.res.Resources.getDrawable(Resources.java:695)

Caused by: org.xmlpull.v1.XmlPullParserException: XML file build\intermediates\res\merged\dev\drawable\abc_ic_ab_back_material.xml line #-1 (sorry, not yet implemented): invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:897)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:837)
at android.content.res.Resources.loadDrawable(Resources.java:2087)

我使用 Robolectric 的其他测试运行正常,只有“setupActivity”测试(其中有几个)。

我知道我也可以使用 SupportFragmentTestUtil.startFragment(fragment) 开始我的 fragment ,但我需要传递“标签”变量

有什么想法吗?

最佳答案

说明

Material means that your sdk should be higher or at least 21, not 18.That's the reason of this error.

解决方案

@Config(sdk = 18)更改为@Config(sdk = 21)或更高版本。

有效。

关于android - Robolectric Resources$NotFoundException :drawable\abc_ic_ab_back_material. 来自可绘制资源 ID 的 xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38747931/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com