Question

I am trying to build a simple OAuth Client for Android in Eclipse.

I followed the instructions from code.google.com/p/google-api-java-client/wiki/Setup

Downloaded the zip file and added google-api-client-1.6.0-beta.jar to my build path in Eclipse. All the 13 dependencies now show up under Referenced Libraries as shown below. Eclipse Projec

The code is simple. I have just done the following changes to the default Activity.

public class Testing1Activity extends Activity {
/** Called when the activity is first created. */

final String                TAG             = getClass().getName();
public static final String  CLIENT_ID       = "";
public static final String  CLIENT_SECRET   = "";
public static final String  REDIRECT_URI    = "";
public static final String  SCOPE           = "https://www.googleapis.com/auth/latitude.all.best";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Json s = new Json();

    String authorizationUrl = new GoogleAuthorizationRequestUrl(CLIENT_ID, REDIRECT_URI, SCOPE)
            .build();
}
}

I keep getting this damn error. :(

W/dalvikvm(  591): Unable to resolve superclass of Lcom/google/api/client/googleapis/auth/oauth2/draft10/GoogleAuthorizationRequestUrl; (18)
W/dalvikvm(  591): Link of class 'Lcom/google/api/client/googleapis/auth/oauth2/draft10/GoogleAuthorizationRequestUrl;' failed
E/dalvikvm(  591): Could not find class 'com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAuthorizationRequestUrl', referenced from method com.rahul.Testing1Activity.onCreate
W/dalvikvm(  591): VFY: unable to resolve new-instance 37 (Lcom/google/api/client/googleapis/auth/oauth2/draft10/GoogleAuthorizationRequestUrl;) in Lcom/rahul/Testing1Activity;
D/dalvikvm(  591): VFY: replacing opcode 0x22 at 0x000d
D/dalvikvm(  591): VFY: dead code 0x000f-001c in Lcom/rahul/Testing1Activity;.onCreate (Landroid/os/Bundle;)V
D/AndroidRuntime(  591): Shutting down VM
W/dalvikvm(  591): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(  591): FATAL EXCEPTION: main
E/AndroidRuntime(  591): java.lang.NoClassDefFoundError: com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAuthorizationRequestUrl
E/AndroidRuntime(  591):    at com.rahul.Testing1Activity.onCreate(Testing1Activity.java:25)
Was it helpful?

Solution

So I finally figured it out myself.

Although eclipse shows all the dependent libs under referenced libraries they are not added to the final apk. One has to explicitly add each one of them to the build path one by one.

Also adding all the dependent libs from zips will create conflicts since some of these api's are already part of the Android framework. They don't need to be added.

OTHER TIPS

Instead of Directly Adding the Reference from the different folder, Please Try to Create lib folder and place that in the Application Folder of the Workspace and then try to Give Reference, it will be resolved. I got my error removed doing the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top