Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nglazkov opened this issue Oct 19, 2018 · 2 comments

Comments

@nglazkov
Copy link

nglazkov commented Oct 19, 2018

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
Copy link

Just encountered same issue.
Seems like this was addressed in scribe 1.3.5 back in 2013 :
scribejava/scribejava@86f12eb#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
Copy link

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" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants