9

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

turtleboy
  • 8,210
  • 27
  • 100
  • 199
  • Please post your code. Is this taken from the tutorials example of the same name? Seems like you either have added something in a namespace it's warning you not to use, or there's something wrong with your setup. Have you successfully built any other android apps yet? – Chris Stratton Dec 06 '10 at 15:31
  • 1
    I am having the same problem, it started one day when I fired up Eclipse. I haven't added any new libraries, changed any project settings, installed any plugins or extensions. Eclipse was fine one day, then this the next day. From what I have been able to figure out the error stems from a class file *in* the android.jar library! – Kingsolmn Apr 28 '11 at 16:06

7 Answers7

5

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.
Shardul
  • 27,760
  • 6
  • 37
  • 35
  • 1
    I am having this same problem, but I have tried everything that I can find on SO and still no fix! It seems the problem is coming from a class file *in* the android.jar library! I starting to pull my hair out! – Kingsolmn Apr 28 '11 at 17:12
  • not a good idea; see http://stackoverflow.com/questions/10315306/repackaging-the-jar-file – JasonPlutext May 10 '12 at 00:08
  • 1
    I think this can only let the compiler resolves the JRE classes. Then you can successfully build the project. However, there should be run-time errors because android JVM cannot find its way to those class resources. – WaiKit Kung Mar 10 '13 at 09:10
1

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.

apoorv020
  • 5,420
  • 11
  • 40
  • 63
0

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.

Setsuki
  • 255
  • 2
  • 11
0

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)

Dhanuka
  • 2,826
  • 5
  • 27
  • 38
SandroG
  • 121
  • 8
0

Check the box of System Library when you add the external jar files through Build Path--Add Libraries--User Library--User Libraries--new

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Bryan
  • 1
0

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

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
AndreasP
  • 19
  • 4
  • Its like fixing compilation issue by removing/commenting offending lines , and keep doing it until the compilation passes. Not the answer to the question downvoting – Abhiram mishra Feb 04 '15 at 07:24
-1

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

bgolson
  • 3,460
  • 5
  • 24
  • 41