Microsoft Graph java Sdk和proguard(适用于Android版本)存在问题

gkl3eglg  于 2023-01-28  发布在  Android
关注(0)|答案(2)|浏览(149)

我在Android应用程序中使用msgraph-sdk-java主要是为了访问OneDrive。在调试模式下一切正常,但当我在发布模式下编译并启用Minify时,我遇到了一个问题。

mGraphServiceClient.me().drive().root().children().buildRequest();

DefaultHttpProvider [sendRequestInternal]-370http请求过程中出错可引发详细信息:com.microsoft.graph.core.ClientException:http请求期间出错..
以及
com.microsoft.graph.core.ClientException:http请求期间出错,网址为:com. microsoft. graph. http. DefaultHttpProvider.发送请求内部(:368)网址为:com. microsoft. graph. http. DefaultHttpProvider.访问$000(:53)网址为:com. microsoft. graph. http. DefaultHttpProvider $www.example.com(:155)网址为:java. util. concurrent.线程池执行程序运行工作程序(线程池执行程序. java:1162)网址为:java. util. concurrent.线程池执行程序$www.example.com(线程池执行程序. java:636)网址为:www.example.com(线程池执行程序. java:764)* 原因是:1.runjava.lang.ClassNotFoundException:Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)**Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImplat javax.ws.rs.ext.RuntimeDelegate.findDelegate(:122) at javax.ws.rs.ext.RuntimeDelegate.getInstance(:91) at javax.ws.rs.core.UriBuilder.newInstance(:69) at javax.ws.rs.core.UriBuilder.fromUri(:80) at com.microsoft.graph.http.BaseRequest.getRequestUrl(:147) at 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?

下面是我在www.example.com文件中尝试的内容:proguard-rules.pro file:

-keep class com.microsoft.** { *; }
-keep class com.microsoft.**
-keep interface com.microsoft.** { *; }
-keepclasseswithmembernames class com.microsoft.** { *; }

-keep class com.sun.ws.** { *; }
-keep class com.sun.ws.**
-keep interface com.sun.ws.** { *; }

-keep class com.sun.jersey.** { *; }
-keep class com.sun.jersey.**
-keep interface com.sun.jersey.** { *; }

我的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()
}

我试过很多方法,但我没有办法。谢谢你的帮助。

fhg3lkii

fhg3lkii1#

这解决了我的问题:

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-gaud条目以保留com.sun.* 类。

yks3o0rb

yks3o0rb2#

这解决了我的问题:
分级:

implementation 'com.sun.jersey:jersey-client:1.12'

在proguard:

-dontwarn com.sun.**
-keep class com.sun.** { *; }
-keep interface com.sun.** { *; }

相关问题