Android版本的Microsoft Graph java Sdk和proguard出现问题
我在我的Android应用程序中主要用于访问OneDrive。 在调试模式下一切正常,但当我在启用minify的发布模式下编译时,我遇到了一个问题Android版本的Microsoft Graph java Sdk和proguard出现问题,java,android,microsoft-graph-api,proguard,Java,Android,Microsoft Graph Api,Proguard,我在我的Android应用程序中主要用于访问OneDrive。 在调试模式下一切正常,但当我在启用minify的发布模式下编译时,我遇到了一个问题 mGraphServiceClient.me().drive().root().children().buildRequest(); DefaultHttpProvider[sendRequestInternal]-370 http过程中出错 请求可丢弃的详细信息:com.microsoft.graph.core.ClientException:
mGraphServiceClient.me().drive().root().children().buildRequest();
DefaultHttpProvider[sendRequestInternal]-370 http过程中出错
请求可丢弃的详细信息:com.microsoft.graph.core.ClientException:
http请求期间出错
及
com.microsoft.graph.core.ClientException:http请求时出错
com.microsoft.graph.http.DefaultHttpProvider.sendRequestInternal(:368)
在com.microsoft.graph.http.DefaultHttpProvider.access$000(:53)上
com.microsoft.graph.http.DefaultHttpProvider$1。运行(:155)于
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
在
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
运行(Thread.java:764)
原因:java.lang.RuntimeException:java.lang.ClassNotFoundException:
com.sun.ws.rs.ext.RuntimeDelegateImpl
javax.ws.rs.ext.RuntimeDelegate.findDelegate(:122)位于
javax.ws.rs.ext.RuntimeDelegate.getInstance(:91)位于
javax.ws.rs.core.UriBuilder.newInstance(:69)位于
javax.ws.rs.core.UriBuilder.fromUri(:80)位于
com.microsoft.graph.http.BaseRequest.getRequestUrl(:147)位于
com.microsoft.graph.http.DefaultHttpProvider.sendRequestInternal(:239)
下面是gradlew myapp:dependencies的返回,其中出现了javax.ws.rs
+--- com.microsoft.graph:microsoft-graph:1.4.+ -> 1.4.0
| +--- org.apache.commons:commons-math3:3.6.1
| +--- com.google.code.gson:gson:2.8.2
| \--- com.sun.jersey:jersey-server:1.19.4
| \--- com.sun.jersey:jersey-core:1.19.4
| \--- javax.ws.rs:jsr311-api:1.1.1// <----here?
my build.gradle,其中我必须排除META-INF/jersey模块版本,因为此文件存在于com.sun.jersey:jersey服务器:1.19.4和com.sun.jersey:jersey核心:1.19.4中:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
flavorDimensions "default"
defaultConfig {
applicationId "com.microsoft.graph.connect"
minSdkVersion 16
targetSdkVersion 28
versionCode 2
versionName "2.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias 'key0'
keyPassword 'tototo'
storeFile file('D:/android-java-connect/connect.jks')
storePassword 'tototo'
}
debug {
keyAlias 'key0'
keyPassword 'tototo'
storeFile file('D:/android-java-connect/connect.jks')
storePassword 'tototo'
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
proguardFile 'D:/sauvegarde/work_space_test/onedrive/proguard-rules.pro'
}
debug {
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
debuggable true
}
}
productFlavors {
legacyDebug {
minSdkVersion 17
}
modernDebug {
minSdkVersion 21
}
}
testOptions {
unitTests.returnDefaultValues = true
}
configurations {
all {
resolutionStrategy.force 'com.android.support:support-annotations:25.3.1'
}
}
dexOptions {
preDexLibraries = false
jumboMode = true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
exclude 'META-INF/jersey-module-version'
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation ('com.microsoft.identity.client:msal:0.1.+') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation 'com.android.volley:volley:1.1.0'
// Include the SDK as a dependency
//implementation 'com.microsoft.graph:msgraph-sdk-android:1.3.2'
implementation('com.microsoft.graph:microsoft-graph:1.4.+')
// Include GSON as a dependency
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'commons-io:commons-io:2.0.1'
// Test libraries
androidTestImplementation 'com.android.support:support-annotations:26.3.1'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test:rules:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:2.2.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-web:2.2.2'
}
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
repositories {
google()
}
}
repositories {
google()
}
我试过很多东西,但我没有主意。谢谢您的帮助。这为我解决了这个问题:
implementation('com.microsoft.graph:microsoft-graph:1.6.0'){
exclude group: 'com.sun.jersey', module: 'jersey-core'
exclude group: 'com.sun.jersey', module: 'jersey-server'
}
implementation(group: 'com.sun.jersey', name: 'jersey-bundle', version: '1.19.4'){
exclude group: 'javax.ws.rs', module: 'jsr311-api'
}
另外,请确保使用相应的pro gaurd条目来保留com.sun.*类
implementation('com.microsoft.graph:microsoft-graph:1.6.0'){
exclude group: 'com.sun.jersey', module: 'jersey-core'
exclude group: 'com.sun.jersey', module: 'jersey-server'
}
implementation(group: 'com.sun.jersey', name: 'jersey-bundle', version: '1.19.4'){
exclude group: 'javax.ws.rs', module: 'jsr311-api'
}