不能编译使用Eclipse一个简单的谷歌API的Andr​​oid应用 [英] Cannot compile a simple Google api Android app with Eclipse

查看:105
本文介绍了不能编译使用Eclipse一个简单的谷歌API的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Eclipse中建立一个简单的OAuth客户端Android版。

我跟着从 code的说明.google.com / p /谷歌API-Java的客户端/维基/设置

下载的zip文件,并添加谷歌API的客户端1.6.0-beta.jar 在Eclipse我的构建路径。现在所有的13依赖性下引用的库显示如下图所示。

在code是简单。我刚才做了以下更改默认的活动。

 公共类Testing1Activity延伸活动{
/ **当第一次创建活动调用。 * /最后的字符串标记=的getClass()的getName()。
公共静态最后弦乐CLIENT_ID =;
公共静态最后弦乐CLIENT_SECRET =;
公共静态最后弦乐REDIRECT_URI =;
公共静态最后弦乐SCOPE =htt​​ps://www.googleapis.com/auth/latitude.all.best;@覆盖
公共无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.main);    JSON S =新的JSON();    字符串authorizationUrl =新GoogleAuthorizationRequestUrl(CLIENT_ID,REDIRECT_URI,SCOPE)
            。建立();
}
}

我不断收到这该死的错误。 (

  W / dalvikvm(591):无法解析的超LCOM /谷歌/ API /客户/ googleapis / auth /中的oauth2 / draft10 / GoogleAuthorizationRequestUrl; (18)
W / dalvikvm(591):类链接LCOM /谷歌/ API /客户/ googleapis / auth /中的oauth2 / draft10 / GoogleAuthorizationRequestUrl;'失败
E / dalvikvm(591):找不到类的com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAuthorizationRequestUrl,从法com.rahul.Testing1Activity.onCreate引用
W / dalvikvm(591):VFY:无法解析新实例37(LCOM /谷歌/ API /客户/ googleapis / auth /中的oauth2 / draft10 / GoogleAuthorizationRequestUrl;)在LCOM /拉胡尔/ Testing1Activity;
D / dalvikvm(591):VFY:更换运$ c。在0x000d $ C 0x22
D / dalvikvm(591):VFY:死code 0x000f-001C在LCOM /拉胡尔/ Testing1Activity; .onCreate(Landroid / OS /束;)V
D / AndroidRuntime(591):关闭VM
W / dalvikvm(591):主题ID = 1:螺纹未捕获的异常(组= 0x40015560)退出
E / AndroidRuntime(591):致命异常:主要
E / AndroidRuntime(591):java.lang.NoClassDefFoundError的:com.google.api.client.googleapis.auth.oauth2.draft10.GoogleAuthorizationRequestUrl
E / AndroidRuntime(591):在com.rahul.Testing1Activity.onCreate(Testing1Activity.java:25)


解决方案

所以,我终于理解了它自己。

虽然蚀示出根据引用的库的所有从属库它们不会添加到最终的apk。其中有一个明确他们每个人加入到构建路径之一。

也增加了所有相关的库从拉链会产生冲突,因为一些API的都已经在Android框架的一部分。它们并不需要被添加

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.

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)

解决方案

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.

这篇关于不能编译使用Eclipse一个简单的谷歌API的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆