Attempt to include a core class (java.* or javax.*

2020-03-14 15:54发布

Hi i'm new android. i'm working through the samples and have an error when running the HelloGridView app. Eclipse is giving the following error. Has anyone had the following error? Thanks.

[2010-12-06 14:38:16 - HelloGridView] trouble processing "javax/net/ServerSocketFactory.class": [2010-12-06 14:38:16 - HelloGridView] Attempt to include a core class (java.* or javax.*) in something other than a core library. It is likely that you have attempted to include in an application the core library (or a part thereof) from a desktop virtual machine. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform. It is also often of questionable legality.

If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, 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 be forewarned that your application will still fail to build or run, at some point. Please be prepared for angry customers who find, for example, that your application ceases to function once they upgrade their operating system. You will be to blame for this problem.

If you are legitimately using some code that happens to be in a core package, then the easiest safe alternative you have is to repackage that code. That is, move the classes in question into your own package namespace. This means that they will never be in conflict with core system classes. If you find that you cannot do this, then that is an indication that the path you are on will ultimately lead to pain, suffering, grief, and lamentation.

[2010-12-06 14:38:16 - HelloGridView] 1 error; aborting [2010-12-06 14:38:16 - HelloGridView] Conversion to Dalvik format failed with error 1

标签: android
7条回答
来,给爷笑一个
2楼-- · 2020-03-14 16:16

Android framework do not allow addition of JAVA core libraries in your project as external jars.

Heres how you can add libraries to your application:

  1. Open project properties by right clicking project and selecting properties
  2. Select JAVA build path on the left pane
  3. Select Libraries tab from right side
  4. Click add Library button
  5. Select JRE system library and add required package.
查看更多
家丑人穷心不美
3楼-- · 2020-03-14 16:26

I had same problem and after a couple of day of search and fight i found this thread. It does not solved my problems but helps me to find the solution. I do this steps mentioned above:

  1. Open project properties by right clicking project and selecting properties.
  2. I saw I had Android 2.1 library and Android 1.6 library.
  3. Removed all libraries.
  4. Changed the Android version of my project from 1.6 to 2.2.1
  5. Clean the project

This solved my problem. The application now is working. BTW, the application I was trying is an Android auto-answer (http://code.google.com/p/auto-answer/source/browse#svn%2Ftrunk%2Fres%2Fdrawable-hdpi)

查看更多
\"骚年 ilove
4楼-- · 2020-03-14 16:30

I was facing the same problem, and noticed that I had added the system JRE library as one of the build path dependencies. However, the problem did not go after removing it.

I then removed the android.jar file as build path dependency, and it started working. Might be it was conflicting with an include from one of the other project dependencies, since the project was dependent on other android projects.

查看更多
家丑人穷心不美
5楼-- · 2020-03-14 16:37

I got rid of this error by checking the project dependencies and removing the Android dependencies.

In Eclipse: Right click on the project -> properties->Java Build Path -> Libraries and there I removed the android dependencies

查看更多
欢心
6楼-- · 2020-03-14 16:39

For people not working in english, it could also be your project name containing special characters (éàè...). I had the same problem, renamed my projects (with F2) and it worked.

查看更多
三岁会撩人
7楼-- · 2020-03-14 16:41

Removing SPACES from an imported project name fixed the problem for me.

查看更多
登录 后发表回答