4

I am currently trying to run through the upload video sample code for Youtube API v3. There is something wrong with the creation of the jetty server. I ran through this code the first time without problems, but now I'm getting an error. Here is how I'm calling the method in the main activity.

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

This is the code inside Auth.class which is where I'm using the jetty server and library.

    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");

Below is the error from the console. The code above are the lines of code in MainActivity and 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

I clearly have the external libraries as shown in the picture below.

enter image description here

I've already added the libraries in dependencies inside 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')
selflearningcode
  • 738
  • 1
  • 7
  • 10

0 Answers0