IllegalArgumentException error after added google jar - java

I get this error
java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream;
and at the bottom of the Log,
Conversion to Dalvik format failed with error 1
after I added the 'libs' folder that includes jar files for google map/place that I'm trying to implement to an existing package.
I've done some research and found a solution which that
Project » Properties » Java Build Path » Libraries and remove all except the "Android X.Y"
but that's not in my case since I can't remove them from the list.(I can remove the Android Dependencies folder but i'm not sure if i should do that)

This issue is that you've got two jar files with duplicate classes. Try removing protobuf, if everything still compiles happily then hey presto you're in luck.
Otherwise, one workaround I found here is:
Add the library project using project properties -> android - add library project.
Add the linked src files to your build path as well.
Build the project. You should see the class files from you library project in the bin folder.
After that, REMOVE the linked src files from the library project in your application >project.
Run your application.
If you clean the project, then repeat these steps from step 2.

Related

Importing an API (UniprotJAPI) into Eclipse

I downloaded an API from Uniprot, which is a protein database, to play around with their code. This is my first time working with an API. The API contains a folder of source files (which includes example code for developers), a folder for classes, a library of JAR files, and an executable command file to run the example code (in cmd, I must execute: runExample.cmd InsertExampleCodeHere )
How do you edit this API? I tried making my own Java project, linked it to the JARS I downloaded, and also transferred over the executable cmd program to my Java project folder. At first, I copied over some of the example code, and added some print statements. When I saved my changes and executed the cmd file, my main class cannot be found. If I tried compiling my java project, I get a bunch of errors - and these errors apply to the example codes Uniprot provides (and while linked to the library of JARs). Is there a particular call (or special command) I must make when compiling my projects?
Thanks in advance!
Hmm, not sure myself as the only real API I was using was a JSON one so I could easily parse it. But, assuming you have a folder that contains of all that, I would imagine you could try to just copy it over to your project's folder and then just add it to build path in a similar vein to how you would add jars. At least that's what I can think of.
Also, you could try this which is a solution I found from the Stackoverflow question titled "How do I important the javax.servlet AOI in my Eclipse project?"
Quick Fix- This worked in Eclipse - Right Click on project -> Properties -> Java Build Path (Tab) -> Add External JARs -> locate the servlet api jar implementation (if Tomcat - its named servlet-api.jar) -> click OK. That's it !!

How to build imported project on Eclipse?

I just imported source folders and required libraries from another PC on which I had been working. The project contains JAVA and Python code in separate packages. Now there seems to be some problem with running the Java parts.
Error: Could not find or load main class Drivers.DependencyFinder
I have tried Cleaning and Building the project. It didn't create any classes in the bin folder. When I copied class files from the older PC, it gives some version error.
I'd like to make a fresh build, removing all the things I had earlier other than the source code. Clicking Build All or Build doesn't produce anything. What's going wrong?
Go to the project properties and check Source tab under Java Build Path. Make sure the proper folders are included in the build path.

Android java.lang.NoClassDefFoundError after import JAR

I got a problem...
I made a Jar (called "GeoFence.jar"), that I have to use on a Android Project.
So, what I done is:
Look In so many webs HowTo's
create "libs" folder in the android project.
add my JAR (manually)
then I went to Java Build Path and checked that my JAR was included to the Android Dependences.
finally I made the necessary Imports to use the class I need from JAR.
After do all of this, I runned my App, and it throws this error:
and I don't understand what's going on, cause, I Fixed the Project Properties and cleaned it. And it's still not working.
Here is how i have the structure and the build path.
for adding jar use below two stpe: but for you just do 2nd.
1. Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.jar
2. Your Project -> right click -> Properties -> Java Build Path -> Order & Export --> Select All --> OK
After taht just clean your Project and RUN.
If you go to you Android Dependencies folder, you should be able to expand the GeoFence.jar file. This way, you should be able to find the class com.elias.polygon.City if you keep expanding subfolders.
If you CANNOT see it, you probably made an error in exporting the jar file.
To solve the export see this question on so
If you CAN see the class, you have an error in your build path/ project properties
To solve the project setup, see this question
the problem that I had, was that the jar I wanted to import, used some packages that in android are not "allowed" so I had to do in a different way.
After that, it happens the same, but the problem was that the Jar was Build in v1.7.
When I builded in v1.6 android accepted it.
So, first of all look for:
Don't use packacges that in android are not allowed
Look in which version is builded the solution.

Getting started with DropboxAPI, class not found

I'm trying to use the Dropbox API for the first time, but i'm getting this error when launching my app.
Caused by: java.lang.NoClassDefFoundError: com.dropbox.client2.session.Session$AccessType
I saw on Dropbox forums a guy with the same problem, and the solution was to rename the class path to libs/ instead of lib/. I did it and didn't work.
I get the error here:
final static private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;
any ideas?
This problem appeared when I imported dropbox jars in the next way:
eclipse project menu -> Build Path -> Configure Build Path -> Libraries -> Add External JARs;
After that, I revert changes, create folder 'libs' in Project Explorer, in 'libs' folder menu select 'Import...' -> File System. Select path and import all jars into 'libs' project folder.
Problem disappear.
My mistake, the problem was the classPath.
I had to add all reference libraries in both the lib and libs folder before it worked, so something is clearly wrong, and for some reason it needs apache-mime4j-0.6 in the lib folder, but the example project from Dropbox on how to implement it don't? can someone from the Dropbox Team deliberate on this? Note: the application used the previous deprecated api, and when I tried updating it with the newest I got this error.
java.lang.NoClassDefFoundError:
com.dropbox.client2.session.Session$AccessType
on
private AccessType ACCESS_TYPE = AccessType.APP_FOLDER;
Working in Eclipse (Luna) I could resolve the error by Project->Properties->Java Build Path->Order And Export and then putting a tick on (in my case for Dropbox 1.6.3) the two Dropbox jar files.
Followed by the usual clean project and run.
This is reproducable by removing the checks marks from the boxes in the Order and Export dialog.
Please check the name of the project libs, its correct name is libs.

commons-logging-1.1.jar; cannot read zip file entry

I have imported a GWT project from GIT , but when i run maven Install
it says
.m2\repository\commons-logging\commons-logging\1.1\commons-logging-1.1.jar; cannot read zip file entry
and if i simply run my application , i get this
\git\my-Search-Engine\qsse\war}: java.lang.NoClassDefFoundError: com/google/inject/servlet/GuiceServletContextListener
I tried to find out the way , one solution i found was to move the guice-servlet-3.0 from build path to \qsse\war\webinf\lib
but if i do that i start getting this exception
ava.lang.NoClassDefFoundError: com/google/inject/Injector
any idea how can i resolve this
For first question:
Can you open it in a WinZip or other compression tool.
Try deleting that jar and build again. Let Maven download it a fresh.
For Second Questin:
Which GWT version are you using ?
Verify that the required JAR is in your classpath including guice.jar and guice-servlet-3.0.jar
And also, guice-servlet-3.0.jar should not be in you launch configuration classpath. It has to be in your project classpath.
For the second question, can you also move the other guice jars to webinf\lib ? (guice-3.0.jar should be missing)

Categories

Resources