Evernote / evernote-sdk-android

Evernote SDK for Android
428 stars 168 forks source link

java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/bind/DatatypeConverter #64

Open nglazkov opened 6 years ago

nglazkov commented 6 years ago

Hello, This is only happening with Android 9 devices. I've upgraded my targetSdkVersion to 28 and migrated to androidX and now I'm catching this issue in crashlytics with this stacktrace:

Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/bind/DatatypeConverter;
       at org.scribe.services.DatatypeConverterEncoder.encode(DatatypeConverterEncoder.java:10)
       at org.scribe.services.HMACSha1SignatureService.bytesToBase64String(HMACSha1SignatureService.java:51)
       at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:46)
       at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:32)
       at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:151)
       at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:75)
       at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:55)
       at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:40)
       at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
       at com.evernote.client.android.EvernoteOAuthHelper.createRequestToken(EvernoteOAuthHelper.java:106)
       at com.evernote.client.android.EvernoteOAuthHelper.startAuthorization(EvernoteOAuthHelper.java:127)
       at com.evernote.client.android.login.EvernoteLoginTask.startAuthorization(EvernoteLoginTask.java:144)
       at com.evernote.client.android.login.EvernoteLoginTask.execute(EvernoteLoginTask.java:51)
       at com.evernote.client.android.login.EvernoteLoginTask.execute(EvernoteLoginTask.java:23)
       at net.vrallev.android.task.Task.executeInner(Task.java:67)
       at net.vrallev.android.task.TaskExecutor$TaskRunnable.run(TaskExecutor.java:191)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.ClassNotFoundException: Didn't find class "javax.xml.bind.DatatypeConverter" on path: DexPathList[[zip file "/data/app/com.appName-wW-VAgs8nrHvdZ5Jsbu0Ag==/base.apk"],nativeLibraryDirectories=[/data/app/com.appName-wW-VAgs8nrHvdZ5Jsbu0Ag==/lib/arm64, /data/app/com.appName-wW-VAgs8nrHvdZ5Jsbu0Ag==/base.apk!/lib/arm64-v8a, /system/lib64]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
       at org.scribe.services.DatatypeConverterEncoder.encode(DatatypeConverterEncoder.java:10)
       at org.scribe.services.HMACSha1SignatureService.bytesToBase64String(HMACSha1SignatureService.java:51)
       at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:46)
       at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:32)
       at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:151)
       at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:75)
       at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:55)
       at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:40)
       at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
       at com.evernote.client.android.EvernoteOAuthHelper.createRequestToken(EvernoteOAuthHelper.java:106)
       at com.evernote.client.android.EvernoteOAuthHelper.startAuthorization(EvernoteOAuthHelper.java:127)
       at com.evernote.client.android.login.EvernoteLoginTask.startAuthorization(EvernoteLoginTask.java:144)
       at com.evernote.client.android.login.EvernoteLoginTask.execute(EvernoteLoginTask.java:51)
       at com.evernote.client.android.login.EvernoteLoginTask.execute(EvernoteLoginTask.java:23)
       at net.vrallev.android.task.Task.executeInner(Task.java:67)
       at net.vrallev.android.task.TaskExecutor$TaskRunnable.run(TaskExecutor.java:191)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)

Can you please help me to fix this. From what I've discovered, the evernote sdk is using this library "org.scribe:scribe:1.3.7", that is quite outdated, maybe this is the issue. Scribe Github Releases

Many thanks!

AndroidGecko commented 5 years ago

Just encountered same issue. Seems like this was addressed in scribe 1.3.5 back in 2013 : https://github.com/scribejava/scribejava/commit/86f12eb5bcc1059833c0b8b19d5eb0c2a1726eaa#diff-fa8deece93206267276c584ef5d0b996

However evernote sdk is using 1.3.7 so should not be happening. For some reason the codec alternative is removed from library, therefore isPresent method properly routes through javax.xml.bind.DatatypeConverter which is unavailable on android causing this crash.

to fix just manually add this dependency to your project so that isPresent routes properly : implementation 'commons-codec:commons-codec:1.10'

nikanorov commented 5 years ago

The simplest solution is to add this in AndroidMainifest.xml in Application tag selection: <uses-library android:name="org.apache.http.legacy" android:required="false" />