Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:41:54+00:00 2026-06-01T08:41:54+00:00

I am trying to use the Google generated API library for the first time

  • 0

I am trying to use the Google generated API library for the first time for Android. I have taken code from the the Sample Program provided by Google. My code looks like

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import android.app.Activity;
import android.os.Bundle;

// Core Google API
import com.google.api.client.auth.oauth2.draft10.AccessTokenResponse;
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessProtectedResource;
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAccessTokenRequest.GoogleAuthorizationCodeGrant;
import com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAuthorizationRequestUrl;
import com.google.api.client.http.ByteArrayContent;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson.JacksonFactory;

// Google+ API
import com.google.api.services.plus.*;

public class GooglePlusActivity extends Activity {

    // Want data about authenticated user
    private static final String SCOPE = "https://www.googleapis.com/auth/plus.me";
    //
    private static final String CALLBACK_URL = "urn:ietf:wg:oauth:2.0:oob";
    //
    private static final HttpTransport TRANSPORT = new NetHttpTransport();
    private static final JsonFactory JSON_FACTORY = new JacksonFactory();

    private static final String CLIENT_ID = "XXXXXXXXXXXXXXX";
    private static final String CLIENT_SECRET = "XXXXXXXXXXXXXX";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // Generate the URL to which we will direct users
        String authorizeUrl = new GoogleAuthorizationRequestUrl(CLIENT_ID,
                CALLBACK_URL, SCOPE).build();

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        try {
            String authorizationCode = in.readLine();

            // Exchange for an access and refresh token
            GoogleAuthorizationCodeGrant authRequest = new GoogleAuthorizationCodeGrant(TRANSPORT,
                JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, authorizationCode, CALLBACK_URL);

            authRequest.useBasicAuthorization = false;

            AccessTokenResponse authResponse = authRequest.execute();

            String accessToken = authResponse.accessToken;

            GoogleAccessProtectedResource access = new GoogleAccessProtectedResource(accessToken,
                TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, authResponse.refreshToken);

            HttpRequestFactory rf = TRANSPORT.createRequestFactory(access);
            System.out.println("Access token: " + authResponse.accessToken);


        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        Plus plus = new Plus(new NetHttpTransport(), new JacksonFactory());

    }
}

However the following line:

private static final HttpTransport TRANSPORT = new NetHttpTransport();

cause an exception:

10-04 13:33:28.954: ERROR/AndroidRuntime(5925): Caused by: java.lang.NoClassDefFoundError: com.google.api.client.http.javanet.NetHttpTransport

I have the following libraries added to the build path:

google-api-client-1.5.0-beta.jar
google-api-services-plus-v1-1.2.2-beta.jar

and these dependency libraries:

guava-r09
httpclient-4.0.3
jackson-core-asl-1.6.7
gson-1.6

I added the dependencies only out of desperation…since I cannot see that I need them. All my import statements are resolved correctly at compile time, so why would I get this error?

I’m using Eclipse Indigo on Windows 7.

I added the following jar files:

google-api-client-1.5.0-beta
google-api-client-extensions-1.5.0-beta
google-api-client-extensions-android2-1.5.0-beta
google-api-services-plus-v1-1.2.2-beta
google-http-client-1.5.0-beta
google-http-client-extensions-1.5.0-beta
google-http-client-extensions-android2-1.5.0-beta
google-oauth-client-1.5.0-beta
google-oauth-client-extensions-1.5.0-beta
gson-1.6
guava-r09
httpclient-4.0.3
httpcore-4.0.1
jackson-core-asl-1.6.7

this resolved my problem. However I am still unsure about how these files correspond to the libraries list on the wiki page and also why they’re required when my imports are resolved during compile time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:41:56+00:00Added an answer on June 1, 2026 at 8:41 am

    You must explicit add library reference of google-http-client-1.5.0-beta.jar(right click project->Properties->Java Build Path->Add External JARs), don’t believe class path.
    If you do not do this, in the apk file does not contain the required data。
    You can download Google plus library from here google-plus-java-starter_v5.zip
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Google visualisation (for the first time - so, please bear
we are trying to use the Google YouTube API to upload videos from our
I am trying to use one-time passwords that can be generated using Google Authenticator
I'm trying to use Google Analytics API to query internal searches that happen on
I'm trying to use Google's SDK Tutorial for Android using Eclipse. I was able
I'm trying to use Google's Images API to search an image and put it
I am trying to use the Google Map API- I've successfully managed to add
I have googled some time now trying to find a good sample application that
I am trying to make use of Google's API as a way to get
I'm currently working with the Google Picasa API trying to list albums. The code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.