我正在使用一个Android项目,该项目使用来自单独JAR文件的类和方法我也在创建,并且问题出在一个名为XpathUtil
的特定util类,每次尝试时抛出一个VerifyError
调用其静态方法之一。java.lang.VerifyError
这里是我XpathUtil类看起来像:
public class XpathUtil {
private static XPath xpath = XPathFactory.newInstance().newXPath();
private static String TAG = "XpathUtil";
public static Document createXpathDocument(String xml) {
try {
Log.d(TAG , "about to create document builder factory");
DocumentBuilderFactory docFactory = DocumentBuilderFactory
.newInstance();
Log.d(TAG , "about to create document builder ");
DocumentBuilder builder = docFactory.newDocumentBuilder();
Log.d(TAG , "about to create document with parsing the xml string which is: ");
Log.d(TAG ,xml);
Document document = builder.parse(new InputSource(
new StringReader(xml)));
Log.d(TAG , "If i see this message then everythings fine ");
return document;
} catch (Exception e) {
e.printStackTrace();
Log.d(TAG , "EXCEPTION OCCURED HERE " + e.toString());
return null;
}
}
public static NodeList getNodeList(Document doc, String expr) {
try {
Log.d(TAG , "inside getNodeList");
XPathExpression pathExpr = xpath.compile(expr);
return (NodeList) pathExpr.evaluate(doc, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return null;
}
// extracts the String value for the given expression
public static String getNodeValue(Node n, String expr) {
try {
Log.d(TAG , "inside getNodeValue");
XPathExpression pathExpr = xpath.compile(expr);
return (String) pathExpr.evaluate(n, XPathConstants.STRING);
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return null;
}
}
而这正是例外,从主体工程发生的确切行,我有工作:
mDocument = XpathUtil.createXpathDocument(xml);
正如你所看到的,我所做的只是简单地调用createXpathDocument
,它位于一个单独的jar文件中,该文件已被成功导入并通过eclipse包含在我的构建路径中(任何其他的调用我都可以从此jar中的不同类运行良好)。所以我不太确定问题是什么。
我尝试做一个干净的和建立在主要项目和我使用的其他项目上,然后将它导出到一个实际的jar文件供第三方应用程序使用,但由于一些奇怪的原因,这个XpathUtil不起作用。
编辑:这里是例外:
Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
java.lang.RuntimeException: An error occured while executing doInBackground()
at
android.os.AsyncTask$3.done(AsyncTask.java:200)
at
java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) at
java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at
java.util.concurrent.FutureTask.run(FutureTask.java:137) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at
java.lang.Thread.run(Thread.java:1096)
Caused by: java.lang.VerifyError:
com.kc.unity.agent.util.xml.XpathUtil at com.kc.unity.agent.util.xml.ContactDescHelper.<init>
(ContactDescHelper.java:67)
at
com.kc.unity.agent.federation.contacts.ContactPlatformWrapper.constructContactDetails
(ContactPlatformWrapper.java:218)
at
com.kc.unity.agent.federation.contacts.ContactPlatformWrapper.getContactDetails
(ContactPlatformWrapper.java:101) at
com.kc.unified.contacts.ContactDetails.setContactFields(ContactDetails.java:154) at com.kc.unified.contacts.ContactDetails.access$6
(ContactDetails.java:150) at
com.kc.unified.contacts.ContactDetails$LoadScreen.doInBackground(ContactDetails.java:79)
at
com.kc.unified.contacts.ContactDetails$LoadScreen.doInBackground(ContactDetails.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185) at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)... 4 more
如果您给出包括堆栈跟踪在内的错误的实际文本将会很有用。有几件事可能会导致'VerifyErrors',目前不可能做更多的猜测。 – 2010-11-05 11:53:30
如果你有jar的源代码,你可以尝试在主项目中包含源代码而不是jar,看看问题是否仍然存在?只是为了确保实用程序不使用Android中不支持的内容。 – 2010-11-05 11:56:13
这就是我设置Suresh的方式,我首先通过eclipse> properties> java build path> projects将整个项目添加到构建路径中。 我将包括实际的异常 – jonney 2010-11-05 12:04:50