Google OAuth客户端API - java.lang.NoClassDefFoundError:解析失败:Lorg / mortbay / jetty / Server

时间:2016-12-10 22:30:30

标签: java android oauth jetty google-api-java-client

我目前正在尝试运行Youtube API v3的上传视频示例代码。 jetty服务器的创建有问题。我第一次遇到这个代码没有问题,但现在我收到了一个错误。以下是我在主要活动中调用该方法的方法。

Credential credential = Auth.authorize(scopes, "uploadvideo", this);

这是Auth.class中的代码,这是我使用jetty服务器和库的地方。

    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, "1012555518316-ir2ni7hasp7963guuouislfskub4a69t.apps.googleusercontent.com",
            "_T5saGdd6zCRdFpmFygIqNJe", scopes).setCredentialDataStore(datastore)
            .build();

    LocalServerReceiver localReceiver = new LocalServerReceiver.Builder().setPort(8080).build();

    // WHERE THE ERROR OCCURS
    return new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user");

以下是控制台的错误。上面的代码是MainActivity和Auth。

中的代码行
W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/mortbay/jetty/Server;
W/System.err:     at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.getRedirectUri(LocalServerReceiver.java:98)
W/System.err:     at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:76)
W/System.err:     at com.google.codelabs.appauth.Auth.authorize(Auth.java:88)
W/System.err:     at com.google.codelabs.appauth.MainActivity.testYoutube(MainActivity.java:593)
W/System.err:     at com.google.codelabs.appauth.MainActivity.onActivityResult(MainActivity.java:818)
W/System.err:     at android.app.Activity.dispatchActivityResult(Activity.java:6932)
W/System.err:     at android.app.ActivityThread.deliverResults(ActivityThread.java:4085)
W/System.err:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132)
W/System.err:     at android.app.ActivityThread.-wrap20(ActivityThread.java)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err:     at android.os.Looper.loop(Looper.java:154)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "org.mortbay.jetty.Server" on path: DexPathList[[zip file "/data/app/com.google.codelabs.appauth-1/base.apk"],nativeLibraryDirectories=[/data/app/com.google.codelabs.appauth-1/lib/x86_64, /system/lib64, /vendor/lib64]]
W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
W/System.err:   ... 16 more

我清楚地有外部库,如下图所示。

enter image description here

我已经在build.gradle中的依赖项中添加了库。

compile files('libs/google-api-client-java6-1.21.0.jar')
compile files('libs/google-oauth-client-java6-1.21.0.jar')
compile files('libs/google-oauth-client-jetty-1.21.0.jar')

0 个答案:

没有答案