Android 使用 javax/net/SocketFactory.class 转换为 Dalvik 格式失败,错误 1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3284407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:28:50  来源:igfitidea点击:

Conversion to Dalvik format failed with error 1 with javax/net/SocketFactory.class

androiddalvik

提问by Arkaha

Encounter this problem when trying to Build Project getting such output in console:

尝试 Build Project 在控制台中获取此类输出时遇到此问题:

[2010-07-19 23:29:23 - myProject]
trouble processing "javax/net/SocketFactory.class":
[2010-07-19 23:29:23 - myProject] 
Attempt to include a core VM class in something other than a core library.
It is likely that you have attempted to include the core library from a desktop
virtual machine into an application, which will most assuredly not work. If
you really intend to build a core library -- which is only appropriate as
part of creating a full virtual machine binary, as opposed to compiling an
application -- then use the "--core-library" option to suppress this error
message. If you go ahead and use "--core-library" but are in fact building
an application, then please be aware that your build will still fail at some
point; you will simply be denied the pleasure of reading this helpful error
message.
[2010-07-19 23:29:23 - myProject] 1 error; aborting
[2010-07-19 23:29:23 - myProject] Conversion to Dalvik format failed with error 1

I was looking for my project to use the package javax, not found, clean all also does not help. what I am doing wrong?

我正在寻找我的项目使用包 javax,没有找到,clean all 也无济于事。我做错了什么?

Update

更新

Sorry guys, but I could not find good fix for that, I want to emphasize the fact, that i dont use SocketFactoryclass in my project at all! source code was not changed before this problem, and that's why i think that problem in eclipse or adt or something else, BUT if i use ant(generated by sdk) to build this project there is no problem!!!

抱歉各位,但我找不到好的解决方法,我想强调一个事实,我SocketFactory在我的项目中根本不使用类!在这个问题之前,源代码没有改变,这就是为什么我认为 eclipse 或 adt 或其他东西中的问题,但是如果我使用 ant(由 sdk 生成)来构建这个项目就没有问题!!!

I solve this problem by removing Eclipse, Android SDK, Eclipse workspace, and just reinstall them, after this all works fine for now.

我通过删除 Eclipse、Android SDK、Eclipse 工作区来解决这个问题,然后重新安装它们,现在一切正常。

Hope this will help someone.

希望这会帮助某人。

回答by prash

I had the same problem.. This worked for me project-->properties->java build path->libraries-> remove all including android jars

我有同样的问题..这对我有用 project-->properties->java build path->libraries-> remove all includes android jars

now go the project browser, right click on the project you are working on, then android tools---> fix project properties... do a clean and then build...

现在转到项目浏览器,右键单击您正在处理的项目,然后 android 工具---> 修复项目属性...做一个清理然后构建...

回答by Spock

  • I solved the problem (at least for me).
  • 我解决了这个问题(至少对我来说)。

Here's what I did:

这是我所做的:

  • Go to Project ? Properties ? Java Build Path ? Libraries
  • Remove all except the "Android X.Y" click OK.
  • Go to Project ? Clean ? Clean projects selected below ? select your project and click OK.
  • 去项目?特性 ?Java构建路径?图书馆
  • 删除除“Android XY”之外的所有内容,单击“确定”。
  • 去项目?干净的 ?下面选择的清洁项目?选择您的项目,然后单击“确定”。

That did the trick for me. Hope it works for you as well

这对我有用。希望它也适用于你

Update: well actually I might have to retract my opinion.. the actions removed the error messages but now I am missing certain classes and methods... arggghhhh

更新:实际上我可能不得不收回我的意见......这些操作删除了错误消息,但现在我缺少某些类和方法...... arggghhhh

回答by Eng.Fouad

I just restarted Eclipse, and the error didn't appear anymore!

我刚刚重新启动Eclipse,错误不再出现!

回答by califan

I had the same problem,and solved it as follows:

我遇到了同样的问题,解决方法如下:

  1. First clean all jars; (This problem must because your some jars)
  2. Delete the project;
  3. Reimport project;
  4. Make sure your sdk is right, and project select one sdk version;
  5. (This is my issue to solve the problem) Right click your project, and select "build-path", next select "add Librarys", and add your private jars; clean-build, the problem has fixed;
  1. 首先清洗所有的罐子;(这个问题一定是因为你的一些罐子)
  2. 删除项目;
  3. 重新导入项目;
  4. 确保你的sdk是正确的,项目选择一个sdk版本;
  5. (这是我要解决的问题)右键单击您的项目,然后选择“build-path”,然后选择“add Librarys”,然后添加您的私有jar;clean-build,问题已经解决;

回答by stealthcopter

I just had the same problem and I tried all of the solutions listed here with no success (I was starting to get annoyed). Then I removed the project from the workspace and then imported it again, and there were no problems!

我刚刚遇到了同样的问题,我尝试了这里列出的所有解决方案,但都没有成功(我开始生气了)。然后我把项目从工作区中删除,然后再次导入,没有任何问题!

回答by Ben Bww

This happened to me this way,

这件事发生在我身上,

I have a quite an old project which I had to start working again today. I use 'Universal Image Downloader' library for basically every project where I have to deal with lots of images. So in this old project I had the source files of 'Universal Image Downloader' included to it's 'src' path. Back then I was a newbie and slowly I started developing my own library which could handle every day simple Android development tasks very easily. Obviously I included the 'Universal Image Downloader' to this.

我有一个很旧的项目,今天我不得不重新开始工作。基本上每个我必须处理大量图像的项目,我都使用“Universal Image Downloader”库。所以在这个旧项目中,我将“Universal Image Downloader”的源文件包含在它的“src”路径中。那时我还是个新手,慢慢地我开始开发自己的库,它可以非常轻松地处理每天简单的 Android 开发任务。显然,我在其中包含了“通用图像下载器”。

After dusting off the old project today the first thing I did was to reference my library to speed up the development process but as I was trying to debug I ran into the "Conversion to Dalvik format failed with error 1" over and over again. First I thought it was the support library but even after clearing all libraries and adding only mine and doing a quick 'Fix project properties' I still got it. After trying various solutions I noticed this in the console "java.lang.IllegalArgumentException: already added: Lcom/nostra13/universalimageloader/cache/disc/BaseDiscCache;"

今天清理旧项目后,我做的第一件事就是引用我的库以加快开发过程,但是当我尝试调试时,我一遍又一遍地遇到“转换为 Dalvik 格式失败,错误 1”。首先,我认为它是支持库,但即使在清除所有库并仅添加我的库并执行快速“修复项目属性”后,我仍然得到它。在尝试了各种解决方案后,我在控制台中注意到了这一点“java.lang.IllegalArgumentException:已经添加:Lcom/nostra13/universalimageloader/cache/disc/BaseDiscCache;”

It was as simple as that... I'm trying to compile a class which has already been compiled.

就是这么简单...我正在尝试编译一个已经编译过的类。

Solution : I just simply removed all the class files I got from 'Universal Image Downloader' library from the 'src' directory. Since my library references "Universal Image Downloader" library the old project started working just fine.

解决方案:我只是简单地从“src”目录中删除了从“Universal Image Downloader”库中获得的所有类文件。由于我的库引用了“Universal Image Downloader”库,因此旧项目开始工作得很好。

回答by Juan Correa

Hit same problem shown on your log when trying to run an example project which was imported into eclipse.

尝试运行导入到 eclipse 中的示例项目时,遇到了日志中显示的相同问题。

Additional Info: in eclipse's Problems View I see the following error:

附加信息:在 eclipse 的问题视图中,我看到以下错误:

"The project cannot be built until build path errors are resolved"

“在解决构建路径错误之前无法构建项目”

In my case the imported project find the libraries just right(by just right I mean I can see the external path to each of the android libs in this case 2 libs, android.jar and maps.jar). So no shuffling of libs in my case, but might be your problem.

在我的例子中,导入的项目找到了恰到好处的库(恰到好处,我的意思是我可以看到每个 android 库的外部路径,在这种情况下是 2 个库,android.jar 和 maps.jar)。所以在我的情况下没有改组库,但可能是你的问题。

I followed Spock's suggestion of cleaning the project which I had to clean multiple times until it somehow resolve its issues. After, issue was solved I had to specify an AVD for the project to run and soon after was up and running on the emulator. Also, note that my eclipse is set up to Build Automatically.

我按照 Spock 的建议清理了我必须多次清理的项目,直到它以某种方式解决了它的问题。之后,问题解决了,我必须为要运行的项目指定一个 AVD,很快就在模拟器上启动并运行。另请注意,我的 eclipse 设置为自动构建。

In my case I'm not missing any class files or anything after the clean as the build is properly generating them.

在我的情况下,我没有丢失任何类文件或清理后的任何内容,因为构建正确生成了它们。

Regards!

问候!

回答by jomarco

I was getting the same error. My problem was that i had an android device hooked up to debug with. As soon as I unplugged it I was able to export.

我遇到了同样的错误。我的问题是我连接了一个 android 设备进行调试。拔掉插头后,我就可以导出了。

回答by rockstar8577

The answer I found was checking the source and library build path in the project's properties. Most likely there will be a duplicate as in something being referenced in both the source and library tabs. So delete the extra in the source tab and then clean the project and you should be good to go.

我找到的答案是检查项目属性中的源代码和库构建路径。很可能会有重复,因为在源和库选项卡中引用的东西。所以删除源选项卡中的额外内容,然后清理项目,你应该很高兴。

回答by Pozinux

I solved the problem by updating available packages in the Android SDK et AVD manager. No need to remove Eclipse.

我通过更新 Android SDK 和 AVD 管理器中的可用包解决了这个问题。无需删除 Eclipse。