title: Google Custom Search API for android ,class not found
body: <p>I need to search google and get back results using my android app. I tried using Google custom search API. It worked fine in java in my desktop. But the same code gives</p>
  
  <blockquote>
    <p>09-07 02:03:25.101: E/dalvikvm(959): Could not find class    'com.google.api.services.customsearch.Customsearch', referenced from method</p>
  </blockquote>
  
  <p>error in the LogCat. But i have included the class in the build path. Can anyone please suggest a way of overcoming this. I have included my full code below</p>
  
  <pre><code>package customSearchAPI.searchTest;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  
  
  import com.google.api.client.http.javanet.NetHttpTransport;
  import com.google.api.client.json.jackson.JacksonFactory;
  import com.google.api.services.customsearch.Customsearch;
  import com.google.api.services.customsearch.model.Result;
  import com.google.api.services.customsearch.model.Search;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.webkit.WebView;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class CustomSearchActivity extends Activity implements OnClickListener{
  
      /** Called when the activity is first created. */
      ListView display;
      ArrayList&lt;String&gt; links=new ArrayList&lt;String&gt;();
      Button searchButton;
      TextView searchBox,output;
      ListAdapter adapter;
      WebView webPage;
      final static  String searchURL = "https://www.googleapis.com/customsearch/v1?";
      // This is Important : 
  
      final static String apiKey = "My API key";
      final static String customSearchEngineKey = "My cx id";
  
      public String makeSearchString(String qSearch){
          String toSearch = searchURL + "key=" + apiKey + "&amp;cx=" + customSearchEngineKey;
          toSearch += "&amp;q=" + qSearch + "&amp;alt=json";
          return toSearch;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          searchBox=(TextView)findViewById(R.id.editText1);
          searchButton=(Button)findViewById(R.id.button1);
          //display=(ListView)findViewById(R.id.listView1);
          webPage=(WebView)findViewById(R.id.webView1);
          output=(TextView)findViewById(R.id.editText2);
      }
  
      public void onClick(View v) {
          // TODO Auto-generated method stub
          Customsearch customsearch = new Customsearch(new NetHttpTransport(), new JacksonFactory());
  
          try {
              com.google.api.services.customsearch.Customsearch.Cse.List list =   customsearch.cse().list(searchBox.getText().toString());
              list.setKey("my api key");
              list.setCx("my cx id ");
              Search results = list.execute();
              List&lt;Result&gt; items = results.getItems();
  
  
              for(Result result:items)
              {
                  //System.out.println("Title:"+result.getHtmlTitle());
                  links.add(result.getHtmlTitle());
              }
              webPage.loadUrl(items.get(0).getLink());
              display.setAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,links));
  
          } catch (IOException e) {
              // TODO Auto-generated catch block
              searchBox.setText("Error"+e.getMessage());
          }
  
      }
  
  }
  </code></pre>