I am using Jackson in my android app.
我在我的android应用程序中使用了Jackson。
I have added these two jars in my build-path:
我把这两个罐子加在了我的构建路径中:
jackson-core-asl-1.0.0.jar
jackson-mapper-asl-1.0.0.jar
But, I keep seeing this in my Logcat:
但是,我一直在我的日志里看到这个:
11-24 18:25:15.093: I/dalvikvm(28842): Could not find method org.codehaus.jackson.map.ObjectMapper.getTypeFactory, referenced from method org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.getJavaType
11-24 18:25:15.093: W/dalvikvm(28842): VFY: unable to resolve virtual method 17967: Lorg/codehaus/jackson/map/ObjectMapper;.getTypeFactory ()Lorg/codehaus/jackson/map/type/TypeFactory;
It's only on that method. I have searched * on similar errors, but all of them were:
只是在那个方法上。我已经搜索了*类似的错误,但是它们都是:
- Libraries wrong versions (mine are correct)
- 库错误版本(我的是正确的)
- Libraries not in /libs but in /lib (i have them in /libs)
- 图书馆不在/libs但在/lib(我有/libs)
My Android version is 4.0.3. I am using this in combination with Spring Android
libraries.
我的安卓版本是4.0.3。我正在使用这个与Spring Android程序库结合使用。
3 个解决方案
#1
13
I had a similar problem; assuming you're using Eclipse, try the following:
我有一个类似的问题;假设您正在使用Eclipse,请尝试以下步骤:
- Right click on your project
- 右键单击项目。
- Go to Build Path > Configure Build Path...
- 去构建路径>配置构建路径…
- Click on the "Order and Export" tab
- 单击“订单和导出”选项卡。
- Check the boxes next to your jars, then click OK
- 检查你的罐子旁边的盒子,然后点击确定。
- Clean and Build your project, then see if it works.
- 清理并构建您的项目,然后查看它是否有效。
Hopefully that works.
希望这工作。
#2
11
This can also happen if you have code calling methods that don't exist in the current device OS version.
如果您有在当前设备OS版本中不存在的代码调用方法,也会发生这种情况。
For example, if somewhere in your app you call Settings.Global.getFloat(String)
- which was added in api 17 - and the current device is running api 15, you will see this warning in your logs.
例如,如果您的应用程序中的某个地方调用Settings.Global.getFloat(String)——它是在api 17中添加的——而当前设备正在运行api 15,您将在日志中看到这个警告。
There will be a crash if you actually try to invoke this method. There is no problem if you don't call this method. So make sure you always check the current version before calling this.
如果您实际尝试调用此方法,将会发生崩溃。如果你不调用这个方法,没有问题。所以在调用之前一定要检查当前版本。
private float getAnimationSetting(ContentResolver contentResolver,
String setting) throws Settings.SettingNotFoundException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return getAnimationSettingJB(contentResolver, setting);
} else {
return getAnimationSettingLegacy(contentResolver, setting);
}
}
private float getAnimationSettingLegacy(ContentResolver contentResolver,
String setting) throws Settings.SettingNotFoundException {
return Settings.System.getFloat(contentResolver, setting);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private float getAnimationSettingJB(ContentResolver contentResolver,
String setting) throws Settings.SettingNotFoundException {
return Settings.Global.getFloat(contentResolver, setting);
}
#3
1
In my case, this solution cannot work.
Check the code format of jar file is fit as JDK 1.6,
I found this issue via changing my lib code format from 1.7 to 1.6, and this issue would be solved.
在我看来,这个解决方案是行不通的。检查jar文件的代码格式是否适合JDK 1.6,我通过将我的lib代码格式从1.7更改为1.6,发现了这个问题,这个问题将得到解决。
- To add a external jar on eclipse for Android Project, we can do as this :
. Project properties -> Java Build Path -> Libraries then add those External Jar file.
. Project properties -> Java Build Path -> Order & Export then checked those External Jar file.
You can clean & re-build the target project to see the apk file size and test those functions in external jar.
- 要在eclipse中为Android项目添加一个外部jar,我们可以这样做:。项目属性-> Java构建路径->库然后添加这些外部Jar文件。项目属性-> Java构建路径-> Order & Export然后检查这些外部Jar文件。您可以清理和重新构建目标项目,以查看apk文件大小并在外部jar中测试这些函数。
- To add a external jar on eclipse for Android Project, we can do as this :
. copy the jar file to libs of android project, and done.
For #1, it is easy to handle multi-projects for one libs.
For #2, it is easy to use and no configure required.
That's all.
- 要在eclipse中为Android项目添加一个外部jar,我们可以这样做:。将jar文件复制到android项目的libs,并完成。对于#1,可以很容易地处理一个libs的多个项目。对于#2,它很容易使用,不需要配置。这是所有。
#1
13
I had a similar problem; assuming you're using Eclipse, try the following:
我有一个类似的问题;假设您正在使用Eclipse,请尝试以下步骤:
- Right click on your project
- 右键单击项目。
- Go to Build Path > Configure Build Path...
- 去构建路径>配置构建路径…
- Click on the "Order and Export" tab
- 单击“订单和导出”选项卡。
- Check the boxes next to your jars, then click OK
- 检查你的罐子旁边的盒子,然后点击确定。
- Clean and Build your project, then see if it works.
- 清理并构建您的项目,然后查看它是否有效。
Hopefully that works.
希望这工作。
#2
11
This can also happen if you have code calling methods that don't exist in the current device OS version.
如果您有在当前设备OS版本中不存在的代码调用方法,也会发生这种情况。
For example, if somewhere in your app you call Settings.Global.getFloat(String)
- which was added in api 17 - and the current device is running api 15, you will see this warning in your logs.
例如,如果您的应用程序中的某个地方调用Settings.Global.getFloat(String)——它是在api 17中添加的——而当前设备正在运行api 15,您将在日志中看到这个警告。
There will be a crash if you actually try to invoke this method. There is no problem if you don't call this method. So make sure you always check the current version before calling this.
如果您实际尝试调用此方法,将会发生崩溃。如果你不调用这个方法,没有问题。所以在调用之前一定要检查当前版本。
private float getAnimationSetting(ContentResolver contentResolver,
String setting) throws Settings.SettingNotFoundException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return getAnimationSettingJB(contentResolver, setting);
} else {
return getAnimationSettingLegacy(contentResolver, setting);
}
}
private float getAnimationSettingLegacy(ContentResolver contentResolver,
String setting) throws Settings.SettingNotFoundException {
return Settings.System.getFloat(contentResolver, setting);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private float getAnimationSettingJB(ContentResolver contentResolver,
String setting) throws Settings.SettingNotFoundException {
return Settings.Global.getFloat(contentResolver, setting);
}
#3
1
In my case, this solution cannot work.
Check the code format of jar file is fit as JDK 1.6,
I found this issue via changing my lib code format from 1.7 to 1.6, and this issue would be solved.
在我看来,这个解决方案是行不通的。检查jar文件的代码格式是否适合JDK 1.6,我通过将我的lib代码格式从1.7更改为1.6,发现了这个问题,这个问题将得到解决。
- To add a external jar on eclipse for Android Project, we can do as this :
. Project properties -> Java Build Path -> Libraries then add those External Jar file.
. Project properties -> Java Build Path -> Order & Export then checked those External Jar file.
You can clean & re-build the target project to see the apk file size and test those functions in external jar.
- 要在eclipse中为Android项目添加一个外部jar,我们可以这样做:。项目属性-> Java构建路径->库然后添加这些外部Jar文件。项目属性-> Java构建路径-> Order & Export然后检查这些外部Jar文件。您可以清理和重新构建目标项目,以查看apk文件大小并在外部jar中测试这些函数。
- To add a external jar on eclipse for Android Project, we can do as this :
. copy the jar file to libs of android project, and done.
For #1, it is easy to handle multi-projects for one libs.
For #2, it is easy to use and no configure required.
That's all.
- 要在eclipse中为Android项目添加一个外部jar,我们可以这样做:。将jar文件复制到android项目的libs,并完成。对于#1,可以很容易地处理一个libs的多个项目。对于#2,它很容易使用,不需要配置。这是所有。