SnappyDB icon indicating copy to clipboard operation
SnappyDB copied to clipboard

java.lang.NoClassDefFoundError: com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy

Open skinner2012 opened this issue 7 years ago • 2 comments

Below is the detailed log:

03-18 05:06:16.608 13927-13927/ xxxx D/dalvikvm: Trying to load lib /data/app-lib/ xxxx-1/libsnappydb-native.so 0xa5012ad8
03-18 05:06:16.608 13927-13927/ xxxx D/dalvikvm: Added shared lib /data/app-lib/ xxxx-1/libsnappydb-native.so 0xa5012ad8
03-18 05:06:16.608 13927-13927/ xxxx I/dalvikvm: Failed resolving Lcom/esotericsoftware/kryo/Kryo$DefaultInstantiatorStrategy; interface 9736 'Lorg/objenesis/strategy/InstantiatorStrategy;'
03-18 05:06:16.608 13927-13927/ xxxx W/dalvikvm: Link of class 'Lcom/esotericsoftware/kryo/Kryo$DefaultInstantiatorStrategy;' failed
03-18 05:06:16.618 13927-13927/ xxxx E/dalvikvm: Could not find class 'com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy', referenced from method com.esotericsoftware.kryo.Kryo.<init>
03-18 05:06:16.618 13927-13927/ xxxx W/dalvikvm: VFY: unable to resolve new-instance 3883 (Lcom/esotericsoftware/kryo/Kryo$DefaultInstantiatorStrategy;) in Lcom/esotericsoftware/kryo/Kryo;
03-18 05:06:16.618 13927-13927/ xxxx D/dalvikvm: VFY: replacing opcode 0x22 at 0x0022
03-18 05:06:16.618 13927-13927/ xxxx I/dalvikvm: Failed resolving Lcom/esotericsoftware/kryo/Kryo$DefaultInstantiatorStrategy; interface 9736 'Lorg/objenesis/strategy/InstantiatorStrategy;'
03-18 05:06:16.618 13927-13927/ xxxx W/dalvikvm: Link of class 'Lcom/esotericsoftware/kryo/Kryo$DefaultInstantiatorStrategy;' failed
03-18 05:06:16.618 13927-13927/ xxxx D/dalvikvm: DexOpt: unable to opt direct call 0x736c at 0x24 in Lcom/esotericsoftware/kryo/Kryo;.<init>
03-18 05:06:16.618 13927-13927/ xxxx D/AndroidRuntime: Shutting down VM
03-18 05:06:16.618 13927-13927/ xxxx W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d3db20)
03-18 05:06:16.618 13927-13927/ xxxx E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process:  xxxx, PID: 13927
                                                                         java.lang.NoClassDefFoundError: com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy
                                                                             at com.esotericsoftware.kryo.Kryo.<init>(Kryo.java:107)
                                                                             at com.esotericsoftware.kryo.Kryo.<init>(Kryo.java:132)
                                                                             at com.snappydb.internal.DBImpl.<init>(DBImpl.java:50)
                                                                             at com.snappydb.DBFactory.open(DBFactory.java:40)
                                                                             at com.snappydb.DBFactory.open(DBFactory.java:65)
                                                                             at com.snappydb.DBFactory.open(DBFactory.java:77)

And this is part of my current build.gradle:

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.2'
    defaultConfig {
        ...
        minSdkVersion 16
        targetSdkVersion 24
        ...
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
       ...
    }
    lintOptions {
        abortOnError false
    }
    productFlavors {
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') { transitive = true }
    ...
    compile group: 'com.pubnub', name: 'pubnub-gson', version: '4.6.0'
    ...
    compile 'com.snappydb:snappydb-lib:0.5.2'
    compile 'com.esotericsoftware.kryo:kryo:2.24.0'
}

apply plugin: 'com.google.gms.google-services'

And this only happened in Android 4.4 and PubNub SDK is 4.X. If I use PubNub 3.X with the same build.gradle, then it works well no matter Android version is 4.4 or 5/6/7. I don't think this is due to SnappyDB. But probably anyone knows other way which could avoid such runtime error? Thanks.

skinner2012 avatar Mar 18 '17 22:03 skinner2012

Possibly a Kryo version mismatch...

Zhuinden avatar Jun 05 '17 15:06 Zhuinden

In my case it was version conflict with another copy included as a dependency for SnappyDB

AlexeyPoldeo avatar Aug 22 '17 08:08 AlexeyPoldeo