Error importing Jar into Android project

This is a recent issue with the new Android SDK.

Now the Android SDK uses the ANT agreement when importing external cans into the apk package, external banks must be in the "lib" folder, and the SDK will ever export banks from this folder.

My problem is when I add my banks and run my project, I get this message:

error handling "javax / transaction / HeuristicCommitException.class":

Explicit or erroneous use of the main class (java. * Or javax. *) When not creating the main library.

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

However, you can try to define a class in the kernel namespace, the source of which you may have taken, for example, from non-Android. It will certainly not be a job. At a minimum, this compromises the compatibility of your application with future versions of the platform. It is also often in doubt Legality.

If you are really going to create a core library that is only relevant as part of creating a full distribution of the virtual machine, as opposed to compiling the application, then use the --core-library to suppress this error message.

If you continue to use "--core-library", but in fact applications, you should be warned that your application will still build or run, at some point. Please be prepared for angry customers who, for example, find that your application stops functioning once they update their operating system. You will be to blame for this problem.

If you are legally using some kind of code that is in the kernel package, then the easiest safe alternative you have is to repackage this code. That is, move the classes in question into your own namespace package. This means that they will never be in conflict with the core of the 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 on will ultimately lead to pain, suffering, sadness, and crying.

I read about this post here and other forums, some people say that the problem with Android.jar is a problem, so the removal will be fixed.

But I can not find this Android.jar, except for the Android lib, which cannot be removed.

This problem about importing android libraries makes me crazy because my application works very well.

+7
source share
3 answers

I saw a lot of problems when I first updated, but in the end I was able to get it working. Some suggestions based on what ultimately worked for me as well as for a friend:

Make sure you have external banks in the “libs” folder in the project’s base directory (note the “s” here, not the “lib”). If you make any changes, be sure to update the project and clean it (then rebuild if you do not configure it automatically).

In the project properties, on the Java Path tab> Libraries tab, delete everything except the Android XXX and Android Dependencies nodes. Again, if you make any changes, be sure to update the project and clean it (then rebuild if it is not installed automatically).

If you have done this for your project and all the library projects that it uses in your workspace and still have problems, try deleting all Android library projects (from project properties> Android), as well as all libraries from the Java build path (in including Android XXX and Android dependencies this time) on each, clear and then change the version of Android / apply / change it back to force rebuild. (Do this for each project, starting with the base library project, adding them only to other projects when they are created without errors).

Hope this helps.

+1
source

Try to clean the project and build it again ... it can help you ... because it helps me ... I also had the same problem with my new sdk ...

+1
source

I got this error in a test project when I was building with Maven. I solved this by adding

<scope>provided</scope> 

to the Android test libraries.

  <dependency> <groupId>com.google.android</groupId> <artifactId>android-test</artifactId> <version>4.1.1.4</version> <scope>provided</scope> </dependency> 
0
source

All Articles