简体   繁体   中英

NoClassDefFoundError: javax.xml.bind.DatatypeConverter

I am using Amazon's Java SDK in my Android app to communicate with SimpleDB. I added the sdk to the gradle file, and it runs until calls DatatypeConverter.printBase64Binary and I get 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 included automatically, or at least in the aws build?

Here's my gradle file in case this helps:

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'
}
}

unfortunately the package javax.xml.bind.* are not available on android so you cannot use the amazon java sdk.

but for android you could use the aws mobile SDK, please visit http://aws.amazon.com/mobile/sdk/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM