I’m very new to Android development (just started today), and also very new to Java development, although I’ve been programming C# for several years.
I’m trying to make an HTTP request using the AndroidHttpClient, but my code won’t even compile.
Eclipse simply highlights the line of code and says, AndroidHttpClient cannot be resolved to a type.
Here’s the code I’m using:
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.net.*;
import android.net.http.*;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AndroidHttpClient client = new AndroidHttpClient();
}
}
I started with an empty Android project after installing the Android SDK and the ADT. What am I missing?
Which API target do you have within your project?
AndroidHttpClientis only for API Level 8 <.If you want to target lower versions of Android you could look at
HttpClientand check if that tool meets your requirements.