我遇到了以下问题:
当尝试通过OAuth2获取凭据时,我得到了运行时异常
java.lang.NoClassDefFoundError: org.mortbay.jetty.Server
at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.getRedirectUri(LocalServerReceiver.java:98)
at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:76)
现在尝试通过依赖项导入jetty并将其排除在其他包中时,我得到以下gradle错误:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK org / mortbay / jetty / build / resources / javadoc.css中复制的重复文件 File1:C:\ Users \ Bene.gradle \ _caches \ modules-2 \ files-2.1 \ org.mortbay.jetty \ jetty \ 7.0.0.pre5 \ e32f430450dffb9c44e525ad7c86aa6efd3a9983 \ jetty-7.0.0.pre5.jar File2:C:\ Users \ Bene.gradle \ _caches \ modules-2 \ files-2.1 \ org.mortbay.jetty \ jetty-util \ 7.0.0.pre5 \ d05f4eb4c5e751ae1ce325b58eed8a51c51f216e \ jetty-util-7.0.0.pre5.jar
在某种程度上看起来在jetty包本身中有一个重复的文件。
我现在要复制我的依赖项和受影响的代码:
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile('com.google.android.gms:play-services-appindexing:8.4.0') {
exclude group: 'com.google.guava'
}
compile('com.google.android.gms:play-services-drive:8.4.0') {
exclude group: 'com.google.guava'
}
// compile 'com.google.api.client:google-api-client-googleapis-extensions-android2:1.4.1-beta'
compile 'com.google.apis:google-api-services-oauth2:v2-rev109-1.22.0'
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
// compile 'com.google.api.client:google-api-client-auth-oauth2:1.2.3-alpha'
compile('com.google.gdata:core:1.47.1') {
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'org.mortbay.jetty'
}
compile('com.google.oauth-client:google-oauth-client-jetty:1.20.0') {
exclude group: 'com.google.api.client.auth.oauth'
exclude group: 'org.mortbay.jetty'
exclude module: 'json'
}
compile 'com.google.http-client:google-http-client-android:1.12.0-beta'
compile('org.mortbay.jetty:jetty:7.0.0.pre5')
"新的LocalServerReceiver"似乎抛出了异常
credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
非常感谢您的帮助!