android kxml2,Android KXmlParser "NoSuchMethodError: java.lang.System.arraycopy([CI[CII)V" - Stack O...

I am using KXmlParser in a Spock specification (no Robolectric) to parse Android strings.xml file. I intermittently get the following trace:

java.lang.NoSuchMethodError: java.lang.System.arraycopy([CI[CII)V

at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1509)

at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:1001)

at org.kxml2.io.KXmlParser.next(KXmlParser.java:448)

at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)

Any idea what could be wrong?

Here are are my ext properties:

minSdkVersion = 19

targetSdkVersion = 26

compileSdkVersion = 26

buildToolsVersion = '26.0.2'

Here is the code snippet:

try (FileInputStream in = new FileInputStream("app/src/main/res/values/strings.xml")) {

XmlPullParserFactory factory = XmlPullParserFactory.newInstance();

factory.setNamespaceAware(true);

XmlPullParser parser = factory.newPullParser();

parser.setInput(in, null);

AndroidStringResource resource = null;

int eventType = parser.getEventType();

while (eventType != parser.END_DOCUMENT) {

eventType = parser.next();

if (eventType == parser.START_TAG) {

if (parser.getName().equals("string")) {

resource = new AndroidStringResource();

resource.name = parser.getAttributeValue(null, "name");

resource.context = parser.getAttributeValue(null, "context");

String maxLengthStr = parser.getAttributeValue(null, "maxLength");

resource.maxLength = (maxLengthStr == null) ? -1 : Integer.parseInt(maxLengthStr);

}

} else if (eventType == parser.TEXT) {

if (resource != null) {

resource.value = parser.getText();

}

} else if (eventType == parser.END_TAG) {

if (parser.getName().equals("string")) {

if (!resourceNameToServerKeyMap.containsKey(resource.name)) {

androidStringResourceMap.put(resource.name, resource);

}

resource = null;

}

}

}

}

Note that I am adding custom XML attributes to elements in my strings.xml. Here is an example:

myapp

An MVCE reproduacble test case is avilable here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值