对于我的
Android项目,我设置了Gradle with
Jackson 2.2.x如下:
// build.gradle buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 18 buildToolsVersion "18.1.0" defaultConfig { minSdkVersion 8 targetSdkVersion 18 } } dependencies { compile 'com.android.support:appcompat-v7:18.0.0' compile 'com.android.support:support-v4:18.0.0' compile 'com.google.android.gms:play-services:3.1.36' compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+' compile 'com.fasterxml.jackson.core:jackson-core:2.2.+' compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+' }
我只是在这里使用ObjectMapper:
import com.fasterxml.jackson.databind.ObjectMapper; // ... ObjectMapper objectMapper = new ObjectMapper(); try { Content content = objectMapper.readValue(inputStream,Content.class); } catch (IOException e) { e.printStackTrace(); }
当我运行gradle installDebug并启动应用程序的相关部分崩溃:
java.lang.NoClassDefFoundError: com.fasterxml.jackson.databind.ObjectMapper
思考:
>我注意到,在build.gradle中定义了com.fasterxml.jackson.core的错误消息中提到了com.fasterxml.jackson ….有不匹配导致问题吗?
>我把这个依赖关系块暂时移动到android块中,因为我found other build.gradle
configurations这样结构化了.不过似乎没有什么区别.