Android 我的安卓应用程序正在获得;故障处理“;错误

Android 我的安卓应用程序正在获得;故障处理“;错误,android,Android,我的android应用程序在Eclipse下运行正常,然后我尝试添加一些在线示例中的GridView示例代码,现在它将不再构建/运行。我不断发现一个主要错误: 处理“javax/net/SocketFactory.class”时出现问题: [2010-08-1017:35:12-克利夫] 尝试在核心库以外的内容中包含核心VM类 我从未在我的任何代码中加入与“SocketFactory”有关的内容。我搜索了所有代码,但找不到任何包含SocketFactory.class的代码 我删除了与GridV

我的android应用程序在Eclipse下运行正常,然后我尝试添加一些在线示例中的GridView示例代码,现在它将不再构建/运行。我不断发现一个主要错误:

处理“javax/net/SocketFactory.class”时出现问题: [2010-08-1017:35:12-克利夫] 尝试在核心库以外的内容中包含核心VM类

我从未在我的任何代码中加入与“SocketFactory”有关的内容。我搜索了所有代码,但找不到任何包含SocketFactory.class的代码

我删除了与GridView有关的xml和我正在处理的类,并恢复到以前运行时的代码,但现在我继续遇到上述错误。我甚至尝试使用“Clean”,但错误仍然存在


有人知道我应该如何处理这个错误吗?

如果您正在使用其他第三方库处理一个更大的项目,请尝试右键单击您的项目,Android工具->修复项目属性,我发现使用maven存储库中的android.jar要好得多

原因是android.jar附带了许多其他库,例如JUnit3。 因此,如果您想使用JUnit4测试,您必须担心这两个.jar在类路径上的位置,这样JUnit3就不会影响您的JUnit4 jar

还请注意,一些第三方库使用了Android不喜欢的包结构。 例如stax-api-1.0.1.jar。它的包结构如下:

javax.xml.stream.events.StartElement.class

因此,当您尝试创建apk文件时,它会告诉您以下信息:

[apply] trouble processing "javax/xml/stream/events/StartElement.class":
[apply] 
[apply] Ill-advised or mistaken usage of a core class (java.* or javax.*)
[apply] when not building a core library.
[apply] 
[apply] This is often due to inadvertently including a core library file
[apply] in your application's project, when using an IDE (such as
[apply] Eclipse). If you are sure you're not intentionally defining a
[apply] core class, then this is the most likely explanation of what's
[apply] going on.
[apply] 
[apply] However, you might actually be trying to define a class in a core
[apply] namespace, the source of which you may have taken, for example,
[apply] from a non-Android virtual machine project. This will most
[apply] assuredly not work. At a minimum, it jeopardizes the
[apply] compatibility of your app with future versions of the platform.
[apply] It is also often of questionable legality.
[apply] 
[apply] If you really intend to build a core library -- which is only
[apply] appropriate as part of creating a full virtual machine
[apply] distribution, as opposed to compiling an application -- then use
[apply] the "--core-library" option to suppress this error message.
[apply] 
[apply] If you go ahead and use "--core-library" but are in fact
[apply] building an application, then be forewarned that your application
[apply] will still fail to build or run, at some point. Please be
[apply] prepared for angry customers who find, for example, that your
[apply] application ceases to function once they upgrade their operating
[apply] system. You will be to blame for this problem.
[apply] 
[apply] If you are legitimately using some code that happens to be in a
[apply] core package, then the easiest safe alternative you have is to
[apply] repackage that code. That is, move the classes in question into
[apply] your own package namespace. This means that they will never be in
[apply] conflict with core system classes. JarJar is a tool that may help
[apply] you in this endeavor. If you find that you cannot do this, then
[apply] that is an indication that the path you are on will ultimately
[apply] lead to pain, suffering, grief, and lamentation.

如果您正在与其他第三方库进行一个更大的项目,我发现使用maven存储库中的android.jar会更好

原因是android.jar附带了许多其他库,例如JUnit3。 因此,如果您想使用JUnit4测试,您必须担心这两个.jar在类路径上的位置,这样JUnit3就不会影响您的JUnit4 jar

还请注意,一些第三方库使用了Android不喜欢的包结构。 例如stax-api-1.0.1.jar。它的包结构如下:

javax.xml.stream.events.StartElement.class

因此,当您尝试创建apk文件时,它会告诉您以下信息:

[apply] trouble processing "javax/xml/stream/events/StartElement.class":
[apply] 
[apply] Ill-advised or mistaken usage of a core class (java.* or javax.*)
[apply] when not building a core library.
[apply] 
[apply] This is often due to inadvertently including a core library file
[apply] in your application's project, when using an IDE (such as
[apply] Eclipse). If you are sure you're not intentionally defining a
[apply] core class, then this is the most likely explanation of what's
[apply] going on.
[apply] 
[apply] However, you might actually be trying to define a class in a core
[apply] namespace, the source of which you may have taken, for example,
[apply] from a non-Android virtual machine project. This will most
[apply] assuredly not work. At a minimum, it jeopardizes the
[apply] compatibility of your app with future versions of the platform.
[apply] It is also often of questionable legality.
[apply] 
[apply] If you really intend to build a core library -- which is only
[apply] appropriate as part of creating a full virtual machine
[apply] distribution, as opposed to compiling an application -- then use
[apply] the "--core-library" option to suppress this error message.
[apply] 
[apply] If you go ahead and use "--core-library" but are in fact
[apply] building an application, then be forewarned that your application
[apply] will still fail to build or run, at some point. Please be
[apply] prepared for angry customers who find, for example, that your
[apply] application ceases to function once they upgrade their operating
[apply] system. You will be to blame for this problem.
[apply] 
[apply] If you are legitimately using some code that happens to be in a
[apply] core package, then the easiest safe alternative you have is to
[apply] repackage that code. That is, move the classes in question into
[apply] your own package namespace. This means that they will never be in
[apply] conflict with core system classes. JarJar is a tool that may help
[apply] you in this endeavor. If you find that you cannot do this, then
[apply] that is an indication that the path you are on will ultimately
[apply] lead to pain, suffering, grief, and lamentation.

谢谢你的帮助,先生。我使用了“修复项目”,但它似乎不起作用。我以后会用它做更多的实验。我最终做的是将所有项目复制到一个新项目中,使用相同的代码,它工作和构建都没有问题。我也遇到过类似的问题,通常复制到一个新项目中会起到作用,但如果是一个大型项目,并且您处于源代码管理等方面,这可能会很痛苦。通常有一个解决方案,通常完全不明显,可能与构建路径有关。您可以尝试删除库,清理库,然后将它们添加回…我遇到了几乎相同的问题,有一天打开Eclipse发现了这个错误。仅供参考-ant似乎正在翻转android.jar库中的“javax/net/SocketFactory.class”!谢谢你的帮助,先生。我使用了“修复项目”,但它似乎不起作用。我以后会用它做更多的实验。我最终做的是将所有项目复制到一个新项目中,使用相同的代码,它工作和构建都没有问题。我也遇到过类似的问题,通常复制到一个新项目中会起到作用,但如果是一个大型项目,并且您处于源代码管理等方面,这可能会很痛苦。通常有一个解决方案,通常完全不明显,可能与构建路径有关。您可以尝试删除库,清理库,然后将它们添加回…我遇到了几乎相同的问题,有一天打开Eclipse发现了这个错误。仅供参考-ant似乎正在翻转android.jar库中的“javax/net/SocketFactory.class”!