Unexplored or erroneous use of the main class (java. * Or javax. *), When the base library is not created

When I clean my project, I get the following error:

[2011-10-05 13:47:53 - The Basics] Dx trouble processing "java/nio/CharBuffer.class": Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. 

This often happens due to the unintentional inclusion of a core library file in your application when using an IDE (e.g. Eclipse). If you are sure that you are not intentionally defining the main class, then this is the most likely explanation for what is going on.

However, you can try to define a class in the kernel a namespace whose source you may have taken, for example, from a virtual machine project other than Android. This will most of all certainly not work. At a minimum, this compromises the compatibility of your application with future versions of the platform. It also often causes dubious legitimacy.

If you really want to create a core library that is only suitable as part of creating a complete distribution virtual machine, as opposed to compiling the application, then use the --core-library option to suppress this error message.

If you continue to use "--core-library", but actually creating the application, then warn that your application at some point will still not be able to build or run. Please be prepared for angry customers who, for example, find that your application stops functioning after updating their working system. You will be to blame for this problem.

If you legally use some kind of code that is in the main package, then the simplest safe alternative that you have is repackaging that code. That is, move the classes in question into your own package namespace. This means that they will never conflict with the main system classes. JarJar is a tool that can help you in this endeavor. If you find that you cannot do this, this indicates that the path you are following will ultimately lead to pain, suffering, grief, and crying.

 [2011-10-05 13:47:53 - The Basics] Dx 1 error; aborting [2011-10-05 13:47:53 - The Basics] Conversion to Dalvik format failed with error 1 
+8
dalvik
source share
4 answers

I had this problem. I use Maven to create my Android projects. My problem was caused by one of my addictions depending on android jars. I updated my pom to exclude android from this dependency and solved it for me.

  <dependency> <groupId>org.reassembler</groupId> <artifactId>synth-android</artifactId> <version>2.5.8</version> <exclusions> <exclusion> <artifactId>junit</artifactId> <groupId>junit</groupId> </exclusion> <exclusion> <artifactId>android</artifactId> <groupId>android</groupId> </exclusion> </exclusions> </dependency> 

Hope this helps someone, it took me a while to figure out what was going on.

+4
source share

In the interest of anyone who might stumble upon this, this problem may be caused by the inclusion of an older library such as android.jar . Removing the .jar file from your build path will allow you to compile. Otherwise, you can use the "jarjar" mentioned in the error message to move the .jar file to another package.

+2
source share

Your IDE is not configured correctly. Make sure your scripts or IDEs do not pass rt.jar or android.jar to dx .

+1
source share

In Android Studio, I included java and javax jar files in my lib folder, and there were dependencies associated with them (in build.gradle at the application level). I commented on them.

 //compile files('libs/ K java-rt-jar-stubs-1.5.0.jar') //compile 'javax.annotation:jsr250-api:1.0' //compile files('libs/javax. annotation.jar') 

Then I went to Project View and deleted the jar files. There were some obsolete instances of java.awt.geom that I had to clean up but restored the project and then I was fine.

0
source share

All Articles