org.apache.http.httpResponce (Not a repost) - android

First of all let me tell you that im a complete noob here. I don't know about programming . But i wanted to compile this project .
With various google searches i found out that this problem is caused because of some upgradation in android sdk.
There were about 56 errors in a project. I managed to solve 54 of them by adding several jars into the java built path. Im sure that the program itself is clean and does not contain any errors. I got it from github. Pictures of errors are provided with this thread.
Im using Eclipse mars by the way.
Errors are as follows
1.The project was not built since its build path is incomplete. Cannot find the class file for org.apache.http.HttpResponse. Fix the build path then try building this project
2.The type org.apache.http.HttpResponse cannot be resolved. It is indirectly referenced from required .class files
Thanks in advance

If you are using Android SDK 23 then HttpResponse and other org.apache classes will be missing. Because, they have been removed. Instead, you could use URLConnection for network communication.

If you still want to use HttpClient in Android -M, Please include following jars
HttpClient : httpclient-4.0-beta2.jar
HttpCore : httpcore-4.1.jar
You can download these jars from here
http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
Put these jars in the libs folder of your project.

Related

Apache httpClient.execute() NoSuchMethodError - project builds ok, but this happens at runtime?

A few days ago I moved my Eclipse project from one folder to another and set up the dependencies again.
The project now builds perfectly and the app runs until it gets to this piece of code:
HttpResponse httpResponse = httpClient.execute(httpPost);
Where I get this error:
Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute
In the libs folder I have these jars:
httpclient-4.3.5.jar
httpcore-4.3.2.jar
httpmime-4.3.5.jar
And here is how my Order and export looks like:
And my libraries tab
EDIT: Another thing I tried was downloading the lastest httpcore, httpclient and httpmime and replacing the jars in the libs folder
And I also added them as Add External Jars in Libraries tab of Configure Build path
I resolved my problem by downgrading to versions 4.1 or httpcore, httpclient and httpmime.
I don't have much idea about how you could resolve the error, especially since you seem to be using Eclipse, but as an alternative, you could try OkHttp library. It has very good performance and you could easily modify your codebase with this change.

Android project complaining "The type bolts.Task cannot be resolved. It is indirectly referenced from required .class files"

I'm trying to go through the Parse Mealspotting tutorial, but after adding the Parse library I'm getting weird errors. I've found other similar errors while googling, but nothing that has worked. Here's one. I also read to look at Adding the Support Libraries, but that didn't fix it.
Exact text is:
Multiple markers at this line
- The type bolts.Task cannot be resolved. It is indirectly referenced from required .class files
- The class file Task<?> contains a signature 'Ljava/util/Set<Lbolts/Task<*>.TaskCompletionSource;>;' ill-formed at
position 30
I don't care about the support libraries or what devices the app will work on, all I want is for this to work so I can go through the tutorial. Has anyone dealt with this before?
I have also tried creating a project that only supports Kit Kat and removed the support libraries, but it's still throwing the same error.
Try to add the bolts-android-1.1.3 lib in your project. You can find it in the Parse SDK zip file.
First, be sure that you have the Parse library in your lib folder.
I had the same problem and solved it by adding the bolts-android-1.1.3.jar (right click on your project properties and then java build path , tab libraries, add jars or externals jars) that i found in Parse-1.7.1.
Then clean your project and it should work.

Android - NoClassDefFoundError after jar changed

I know that there are some similar questions, but no solution helped me.
I am getting a java.lang.NoClassDefFoundError when I try to access an (existing) class
in a self-created .jar from my projectgroup.
This .jar works fine in an normal javaProject but doesn´t work with Android.
But an older version of this .jar worked fine with Android.
I am developing with Eclipse + Android Development Tool - Plugin (Version 21)
I have put the .jar in the Project_Home/libs folder.
There are no errors at compiletime.
Before the exception was thrown, there was some "dalvikvm - could not find class ... referenced from ..." errors.
I think, there could be a problem with the Java Version, because our projectgroup recently started to use Java 7, but I am not sure and have no idea how to fix it.
Thanks a lot for your help.
Rename your lib to libs and update the build path and then try again
I think if the project is compiling fine then we can rule out any error in copying or java buildpath. The only other time i get this error is when my import is wrong in the code. I would suggest you to re-check your import and recreate R.java file.
Make sure that your classes do not have same names as ones already present within Android. Upon building the package, due to "optimization" classes with same names are omitted.
Android libraries are mostly compiled against 1.5. Not all libraries are also present within Android. Your package may depend on some other library that is not present within the system.
Ordinarily I don't want to answer my own question but I hope it will help someone.
I didn't see an other warning (not in Logcat, it was in the console):
"Dx bad class file magic (cafebabe) or version (0033.0000)"
I had found this Warning in an other Stackoverflow question.
I had opened one of the class file from the not working .jar with an HexEditor
and changed the Major-Version-Byte to 0x32 and it worked.
I know this is not a solution, because there could be features from Java 7 in the class,
so the class file no longer work, but it proves that it was a problem with the Java version

ERROR: "._android-support-v4.jar" in project FacebookSDK

Help needed!!!! Stuck for 2 weeks on this and help needed.
I've recently imported the facebook sdk for android and its projects into my workspace. It shows up errors and the problems:
Archive for required library: '/home/Documents/facebook-android-sdk-3.0.2.b/facebook/libs/._android-support-v4.jar' in project 'FacebookSDK' cannot be read or is not a valid ZIP file
And the samples get errors along the line of:
The container 'Android Dependencies' references non existing library '/home/Documents/facebook-android-sdk-3.0.2.b/facebook/bin/facebooksdk.jar'
The things I have done following the other discussions without any success are
cleaned project
set the Facebook SDK as library
looked at the build path section and added external jar consisting of facebook/libs
imported fb sdk like 20 times and into different folders.
made sure my java compiler was 1.6
HELP would be very greatly appreciated!!!!
Take the lastest version of android-support-v4.jar (in your sdk environement : sdk/extras/android/support/v4/android-support-v4.jar) and replace in your project and library project do not create conflict.
The steps to importing a library are:
Download the library
Place the library in the libs folder of the project.
Build the project
Do Not attempt to import the library using some import wizard.
I suspect either your download was corrupted, and you need to do it again, or you put the file into the wrong directly.
I think your problem is that the android.support.v4 versions are different, take the one from your project and replace the one in the Facebook sdk lib folder, it should dismiss the clash.
As per your question, I think you are not able to compile once you add the SDK to your project. Do you get an error saying unable to run as library?
If so that means you have included this as library and create your project as a library to be used further. It is a common mistake that I have seen many people do when they try to import a library to use and tick mark the checkbox is Library. This actually means you want this project to be treated as a library for future use. Just try to add the SDK and do not tick mark the checkbox and this project will run fine.
Many forums will just tell you to tick that checkbox and you will be stuck on this error for long time.
For any .jar file related issues you have to make the .jars files compatible as there hashing a problem and the two jars are not compatible with each other (a version issue).

Regarding NoClassDefFoundError

I have used the isEmpty and isBlank methods of apache's StringUtils Class. These methods worked in a fine manner, after couple of weeks suddenly i got the error
java.lang.NoClassDefFoundError: org.apache.commons.lang3.StringUtils
I was confused why this error happened suddenly.It would be fine if anyone help me to understand this suddenly happened.
People Saying that apache might have changed the definitionin their JAR file, is it a right one,i really confused why this suddenly happened , i removed the old jar from my build path and downloaded the same version of New Jar and added it to Build path, then this issue is resloved.
It is happening in the Market Code , there's no interaction with ADT and market code
so really confused on this issue?
This occurred to me too - after updating the Android SDK Tools. In current version (19), what you need to do is:
make libs/ folder in project's root directory, and put all jars there (folder's name is fixed "libs")
after this, go to project properties --> Java Build Path --> Libraries, and remove all custom jars you previously added
NoClassDefFoundError says NoClassDefFoundError is Thrown if the JVM or a ClassLoader instance tries to load in the definition of a class and no definition of the class could be found.
Maybe startup script is overriding Classpath environment variable.

Categories

Resources