意外的顶级例外:java.lang.IllegalArgumentException:如果已经添加 [英] UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added

查看:370
本文介绍了意外的顶级例外:java.lang.IllegalArgumentException:如果已经添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Andr​​oid,尝试推出的项目,该项目正在建设中,并部署好了。但每次我做一个尝试启动Eclipse中的应用程序,我得到这个错误:

I'm new to Android, trying to launch the project, which is being built and deployed well. But every time I make a try to start the app from eclipse, I get this error:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/.../model/AvailabilityRequest$DAY_TIME_PREFERENCE;
[2012-02-06 17:32:11 - main-app] Dx     at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2012-02-06 17:32:11 - main-app] Dx     at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2012-02-06 17:32:11 - main-app] Dx     at com.android.dx.command.dexer.Main.processClass(Main.java:486)
...
[2012-02-06 17:32:11 - main-app] Dx     at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2012-02-06 17:32:11 - main-app] Dx 1 error; aborting
[2012-02-06 17:32:11 - main-app] Conversion to Dalvik format failed with error 1

我杀了的时候大量的这种愚蠢的事情。显然,这是众所周知的问题,但没有为我工作。
我有:

I've killed enormous amount of time for this stupid thing. Obviously, this is known problem, but nothing works for me.
What I have:

操作系统 - OS X ,这是很重要的,我认为,
IDE - 日食3.7.1
ADT - 版本:15.0.1.v201111031820-219398
构建工具 - 的Maven

Operation system - OS X, which is important I think;
IDE - eclipse 3.7.1
ADT - Version: 15.0.1.v201111031820-219398
Build tool - Maven

我试过到目前为止:
  - 属性 - > Java构建Path->库删除除了Android的XYZ的所有库,然后Maven->更新项目的配置,还清理项目;
  - 魔术与关闭​​和重新打开蚀;
  - 共舞与删除并重新创建项目和库它(根据错误消息的文本,有一些重复的来源,这是在2图书馆之一,在主要项目中使用)

What I've tried so far:
- Properties->Java Build Path->Libraries to remove all the libraries except Android x.y.z, then Maven->Update Project Configuration, also to clean the project;
- Magic with closing and reopening eclipse;
- Dances with deleting and recreating the project and the libraries for it (according to the text of error message, there is some duplication of the sources, which are in one of the 2 libraries, used in the main project).

在上面的变体(通常1日1),它开始工作,但我可以花20分钟,使其工作或几个小时......,今天我不能设法做到这一点在所有之一。

After one of the variants above (usually the 1st one) it starts to work, but I can spend 20 mins to make it work or several hours..., today I can't manage to do it at all.

任何想法是AP preciated。

Any idea would be appreciated.

推荐答案

嗯,据我了解,这里的主要的事情是,我使用的行家作为建筑工具。我可以建立,没有任何问题,部署的项目,但我不能从环境(蚀)启动它。

Well, as far as I understand, the main thing here was that I was using maven as a building tool. I could build and deploy project without any problem, but I couldn't start it from the environment (eclipse).

如果我没有错,当你去到Eclipse的的运行 - >运行配置的,并创建一个 Android应用程序的启动项目,基本上你问蚀(安卓SDK)与蚂蚁构建.apk文件给你,不使用Maven。 Eclipse构建使用Ant的项目,并推动产生.apk文件到设备/模拟器。但是,由于该项目的所有设置都在的 .pom 的文件,蚂蚁不能生成项目,并给出了这样的错误。

If I'm not wrong, when you go to eclipse's Run->Run Configurations and create an Android Application to launch your project, you basically ask eclipse (Android SDK) to build the .apk with Ant for you, not with maven. Eclipse builds the project with Ant and pushes the generated .apk to the device/simulator. But since all the settings of the project are in .pom files, Ant can't build the project and gives the errors of this kind.

解决方法:
启动您的应用程序直接从设备/模拟器已部署之后,不通过的运行的菜单。 如果你想为调试您的应用程序,使用DDMS调试,而不是一个Eclipse提供。 如果你不知道在哪里DDMS是(像我在我的情况) - 在的Mac 窗口 - >打开Perspective->其他... 的从菜单中选择DDMS ;你可以把它作为一个书签与Eclipse的调试的Java 的。在DDMS你会发现所有的很酷的工具,包括调试。

Solution:
Start your app right from the device/simulator after you deployed it, not through Run menu. If you want to debug your app, use DDMS' debug, not the one eclipse provides. In case you don't know where DDMS is (like me in my case) - in Mac it's Window->Open Perspective->Other... choose DDMS from menu; you can put it as a bookmark together with eclipse's Debug and Java. In DDMS you'll find all the cool tools, including debug.

P.S。这是一个初学者,初学者的回应......如果你看到的东西,我错了,请让我知道或随意编辑我的答案。

P.S. This is a response from a beginner and for beginners... If you see something where I'm wrong, please, let me know or feel free to edit my answer.

这篇关于意外的顶级例外:java.lang.IllegalArgumentException:如果已经添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆