适用于android的Firebase:java.lang.NoClassDefFoundError:com.fasterxml.jackson.databind.ObjectMapper

时间:2017-01-26 16:12:07

标签: android firebase crash

我正在尝试使用firebase数据库,但我无法摆脱以下错误:

E/AndroidRuntime: FATAL EXCEPTION: main process:
com.example.useer.instantmessagingapp, PID: 21379
java.lang.NoClassDefFoundError:com.fasterxml.jackson.databind.ObjectMapper 
at com.firebase.client.core.view.QueryParams.<clinit>(QueryParams.java:36)
at com.firebase.client.Firebase.<init>(Firebase.java:182)

这里是gradle:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 24
  buildToolsVersion "24.0.3"
  defaultConfig {
      applicationId "com.example.useer.instantmessagingapp"
      minSdkVersion 17
      targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt')
      'proguard-rules.pro'
          }
      }
  }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
 exclude group: 'com.android.support', module: 'support-annotations'
})
 compile('com.firebase:firebase-client-android:2.3.1', {
 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-bind'
 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-crash:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

我将以下内容添加到项目级别gradle中: classpath'com.android.tools.build:gradle:2.2.3' classpath'com.google.gms:google-services:3.0.0'

1 个答案:

答案 0 :(得分:1)

删除以下依赖:

 compile('com.firebase:firebase-client-android:2.3.1', {
 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-bind'
 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
})

这是用于firebase.com的旧库,现在替换为:

compile "com.google.firebase:firebase-database:10.0.1"