2016-09-23 7 views
7

Ich benutze Microsoft AAD: Adal4j, um die Dynamik CRM-Login von Mobile zu behandeln. Nach der Implementierung bekomme ich die folgende Ausnahme.Android Microsoft Dynamics CRM Adal4j Login Problem

Was mache ich falsch?

Fehler

java.lang.NoSuchMethodError: No static method encodeBase64URLSafeString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar) 
java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: No static method encodeBase64URLSafeString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar) 
at java.util.concurrent.FutureTask.report(FutureTask.java:94) 
at java.util.concurrent.FutureTask.get(FutureTask.java:164) 
at com.sampleadal.MainActivity.onCreate(MainActivity.java:33) 
at android.app.Activity.performCreate(Activity.java:6237) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.NoSuchMethodError: No static method encodeBase64URLSafeString([B)Ljava/lang/String; in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar) 
at com.microsoft.aad.adal4j.AuthenticationContext.computeSha256Hash(AuthenticationContext.java:798) 
at com.microsoft.aad.adal4j.AuthenticationContext.logResult(AuthenticationContext.java:775) 
at com.microsoft.aad.adal4j.AuthenticationContext.access$200(AuthenticationContext.java:61) 
at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:130) 
at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:117) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 

Code

AuthenticationResult result = (AuthenticationResult) new AuthenticationContext(Constants.AUTHORITY_URL, false, Executors.newFixedThreadPool(1)).acquireToken(Constants.SERVICE_URL, Constants.CLIENT_ID, "my_login_id", "my_password", null).get(); 
Log.d("TAG", "Access Token - " + result.getAccessToken() + " \n Refresh Token - " + result.getRefreshToken() + " \n ID Token - " + result.getAccessToken() + " \n User ID - " + result.getUserInfo().getUniqueId() + " \n Displayable ID - " + result.getUserInfo().getDispayableId()); 

Gradle Datei

compile 'com.microsoft.aad:adal4j:0.0.2' 

Und auch dies versucht:

Code:

AuthenticationResult result = (AuthenticationResult) new AuthenticationContext(Constants.AUTHORITY_URL, false, Executors.newFixedThreadPool(1)).acquireToken(Constants.SERVICE_URL, new ClientCredential("my_login_id", "my_password"), null).get(); 

Ausgabe

{ 
    "error": "unauthorized_client", 
    "error_description": "AADSTS70001: Application with identifier 'prasanth' was not found in the directory windows.net\r\nTrace ID: 8c5ccd53-af99-4ff0-8556-501a53080d2f\r\nCorrelation ID: 8651e7f1-a7db-4673-aafb-52fef0d48d2d\r\nTimestamp: 2016-09-26 06:10:41Z" 
} 
+1

Bitte überprüfen Link: http://stackoverflow.com/questions/9126567/method-not-found-using-digestutils-in-android/29833101#29833101 – abhishesh

+0

@abhishesh Ich habe bereits versucht, dass –

+0

@ PrasanthS hast du deine eigene umbenannte Version der Apache Commons-Bibliothek hinzugefügt und die Paketnamen in 'com.microsoft.aad: adal4j' geändert? –

Antwort

1

@abhishesh bereits auf die richtige Lösung hingewiesen. Die Adald4j-Bibliothek für Java wurde nicht für Android entwickelt und verwendet eine andere Version der Apache Commons-Bibliothek als Android intern. Ich stieß auf das gleiche Problem mit der figo Connect API (www.figo.io).

Was müssen Sie tun:

  1. Laden Sie die adald4j Bibliothek https://github.com/AzureAD/azure-activedirectory-library-for-java und fügen Sie es lokal zu einem Projekt.

  2. Laden Sie die Apache Commons-Bibliothek herunter und benennen Sie alle Paketnamen um (z. B. "org.apache.commons.codec.android"). Verwenden Sie zum Beispiel Suchen und Ersetzen über mehrere Dateien in erhabenen Text. Fügen Sie die Bibliothek apache commons auch lokal hinzu.

  3. Benennen Sie alle in Ihrer heruntergeladenen Bibliothek adald4j üblichen Paketimplementierungen von Apache in Ihren neuen angegebenen Namen um. Dies stellt sicher, dass die Bibliothek Ihre Apache Commons-Version und nicht die Android-interne Version verwendet.

Verwandte Themen