NoClassDefFoundError : javax. xml.bind.DatatypeConverter… here is a solution to the problem.
NoClassDefFoundError : javax. xml.bind.DatatypeConverter
I use Amazon’s Java SDK to communicate with SimpleDB in my Android application. I added the sdk to the gradle file and it ran until I called DatatypeConverter.printBase64Binary
and I got the following error:
java.lang.NoClassDefFoundError: javax.xml.bind.DatatypeConverter
at com.amazonaws.util.Base64.encodeAsString(Base64.java:36)
at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:69)
Shouldn’t the JavaX library be automatically included, or at least included in the AWS build?
If this helps, here is my gradle file:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
Support Libraries
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.android.support:support-v4:22.0.0'
compile 'commons-codec:commons-codec:1.5'
compile 'com.amazonaws:aws-java-sdk:1.9.24'
compile 'com.facebook.android:facebook-android-sdk:3.23.1'
compile 'com.github.markushi:android-ui:1.2'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.afollestad:material-dialogs:0.6.4.5'
compile 'com.android.support:multidex:1.0.0'
compile project(':libraries:MaterialNavigationDrawerModule')
compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
transitive = true;
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
targetSdkVersion 21
minSdkVersion 14
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions{
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
Solution
Unfortunately, the
package javax.xml.bind.* is not available on Android, so you can’t use the Amazon Java SDK.
But for Android, you can use the AWS Mobile SDK at http://aws.amazon.com/mobile/sdk/