我正在尝试在 Eclipse 中为 Android 构建一个简单的 OAuth 客户端。
我按照code.google.com/p/google-api-java-client/wiki/Setup的说明进行操作
下载 zip 文件并添加google-api-client-1.6.0-beta.jar
到我在 Eclipse 中的构建路径中。所有 13 个依赖项现在都显示在 Referenced Libraries 下,如下所示。
代码很简单。我刚刚对默认 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();
}
}
我不断收到这个该死的错误。:(
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)