java.lang.VerifyError [英] java.lang.VerifyError
问题描述
我正在使用的类和方法,从一个单独的JAR文件中,我也创建一个Android项目,这个问题是与特定的Util类名为 XpathUtil
的是的VerifyError
每次我试图调用它的静态方法之一抛出。
下面是我的XpathUtil类是这样的:
公共类XpathUtil {
私有静态的XPath的XPath = XPathFactory.newInstance()newXPath()。
私有静态字符串变量=XpathUtil;
公共静态文件createXpathDocument(XML字符串){
尝试 {
Log.d(TAG,关于创建文档生成器工厂);
DocumentBuilderFactory的docFactory =的DocumentBuilderFactory
.newInstance();
Log.d(TAG,关于创建文档构建);
DocumentBuilder的建设者= docFactory.newDocumentBuilder();
Log.d(TAG,讲述与解析XML字符串,它是创建文件:);
Log.d(TAG,XML);
文献文件= builder.parse(新的InputSource(
新StringReader(XML)));
Log.d(TAG,如果我看到这个消息,然后万物精);
返回文档;
}赶上(例外五){
e.printStackTrace();
Log.d(TAG,异常出现的位置+ e.toString());
返回null;
}
}
公共静态节点列表getNodeList(DOC文件,字符串表达式){
尝试 {
Log.d(TAG,里面getNodeList);
XPathEx pression pathExpr = xpath.compile(表达式);
返程(节点列表)pathExpr.evaluate(DOC,XPathConstants.NODESET);
}赶上(XPathEx pressionException E){
e.printStackTrace();
}
返回null;
}
//提取用于给定的EX pression的字符串值
公共静态字符串getNodeValue(节点N,字符串表达式){
尝试 {
Log.d(TAG,里面getNodeValue);
XPathEx pression pathExpr = xpath.compile(表达式);
回报(字符串)pathExpr.evaluate(N,XPathConstants.STRING);
}赶上(XPathEx pressionException E){
e.printStackTrace();
}
返回null;
}
}
而这正是从主项目,我有工作在异常发生的确切行:
mDocument = XpathUtil.createXpathDocument(XML);
正如你所看到的,我做的是简单的通话 createXpathDocument
位于从每次通过Eclipse已经成功地导入和包含在我的构建路径中一个单独的jar文件(任何其它呼叫我做不同类别的从这个罐子正常工作)。所以我也不太清楚是什么问题。
我试着做一个干净的,并建立在两个主要项目,我使用了我然后将其导出为第三方应用使用一个实际的jar文件的其他项目,但由于一些奇怪的原因,这XpathUtil行不通的。
编辑:这里是个例外:
未捕获的处理程序:线程的AsyncTask#1退出,由于未捕获的异常
java.lang.RuntimeException的:执行doInBackground时出错()
在
android.os.AsyncTask $ 3.done(AsyncTask.java:200)
在
java.util.concurrent.FutureTask中$ Sync.innerSetException(FutureTask.java:273)在
java.util.concurrent.FutureTask.setException(FutureTask.java:124)
在
java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:307)
在
java.util.concurrent.FutureTask.run(FutureTask.java:137)在
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
在
java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:561)
在
java.lang.Thread.run(Thread.java:1096)
致:java.lang.VerifyError:
com.kc.unity.agent.util.xml.XpathUtil在com.kc.unity.agent.util.xml.ContactDescHelper< INIT>
(ContactDescHelper.java:67)
在
com.kc.unity.agent.federation.contacts.ContactPlatformWrapper.constructContactDetails
(ContactPlatformWrapper.java:218)
在
com.kc.unity.agent.federation.contacts.ContactPlatformWrapper.getContactDetails
(ContactPlatformWrapper.java:101)在
com.kc.unified.contacts.ContactDetails.setContactFields(ContactDetails.java:154)在com.kc.unified.contacts.ContactDetails.access $ 6个
(ContactDetails.java:150)在
com.kc.unified.contacts.ContactDetails $ LoadScreen.doInBackground(ContactDetails.java:79)
在
com.kc.unified.contacts.ContactDetails $ LoadScreen.doInBackground(ContactDetails.java:1)
在android.os.AsyncTask $ 2.call(AsyncTask.java:185)在
java.util.concurrent.FutureTask中$ Sync.innerRun(FutureTask.java:305)... 4个
在我UPDATA ADT工具18.0.0.v201203301601-306762版本 我也得到了异常,当我运行应用程序.... 终于我找到了ADT更新问题的解决。 当你构建Android应用程序的项目,你需要到项目的属性 - >订单和出口,然后让第三方罐子复选框进行检查,清洁和重建项目。 这个问题将被修复...... 例如
I am working on an Android project that uses classes and methods from a seperate JAR file I am also creating, and the issue is with a specific util class called XpathUtil
that is throwing a VerifyError
every time I try calling one of its static methods.
Here is how my XpathUtil class looks like:
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;
}
}
And this is the exact line where the exception occurs from the main project I am working with:
mDocument = XpathUtil.createXpathDocument(xml);
As you can see, all I'm doing is simple calling createXpathDocument
that is located from a seperate jar file that's been succesfully imported and included in my build path via eclipse (any other call I make to different classes from this jar works fine). So I'm not too sure what the issue is.
I tried doing a clean and build on both the main project and the other project I am using that I then export it to a actual jar file for third party apps to use, but for some strange reason this XpathUtil doesnt work.
edit: here is the exception:
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
When I updata ADT tool to version 18.0.0.v201203301601-306762 I also get the exception when I run the app.... finally i found the solution with adt update issue. When you build the android app project, you need to go to project Properties-> Order and Export, and let the third party jar checkbox to be checked, and clean and rebuild the project. The problem would be fixed......for example
这篇关于java.lang.VerifyError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!