使用谷歌番石榴与Android 1.6 [英] Using Google Guava with Android 1.6

查看:156
本文介绍了使用谷歌番石榴与Android 1.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Andr​​oid应用程序的番石榴R09库,但我得到以下错误,当我使用它与1.6。这是一个有些奇怪,因为它工作正常在1.5。此外,这是未找到的方法是很明显存在的。我也试过,包括jsr305.jar文件,但仍不能正常工作。

鸭preciate任何帮助,执行I / O在Java中是那么的痛苦,而不番石榴。

这是在code:

 字符串时间戳= CharStreams.toString(
    CharStreams.newReaderSupplier(timestampFile,Charset.forName(UTF-8)));
 

这是个例外:

 十二月5日至8日:16:41.163:ERROR / dalvikvm(335):找不到方法com.google.common.io.LineReader< INIT>中的方法引用。 com.google.common.io.CharStreams.readFirstLine
十二月5日至八号:16:41.163:WARN / dalvikvm(335):VFY:无法解决直接的方法6798:LCOM /谷歌/普通/ IO / LineReader;< INIT> (Ljava /朗/可读;)V
十二月5日至八号:16:41.163:WARN / dalvikvm(335):VFY:拒绝运code 0x70为0x0009
十二月5日至八号:16:41.163:WARN / dalvikvm(335):VFY:拒绝LCOM /谷歌/普通/ IO / CharStreams; .readFirstLine(LCOM /谷歌/普通/ IO / InputSupplier;)Ljava /朗/字符串;
十二月5日至八号:16:41.163:WARN / dalvikvm(335):验证拒绝类LCOM /谷歌/普通/ IO / CharStreams;
十二月5日至八号:16:41.163:DEBUG / AndroidRuntime(335):关闭虚拟机
十二月5日至八号:16:41.163:WARN / dalvikvm(335):主题ID = 3:线程退出与未捕获的异常(组= 0x4001aa28)
十二月5日至八号:16:41.173:ERROR / AndroidRuntime(335):未捕获的处理程序:螺纹主力退出,由于未捕获的异常
十二月5日至八号:16:41.183:ERROR / AndroidRuntime(335):java.lang.VerifyError:com.google.common.io.CharStreams
        在com.triposo.droidguide.rometest.LocationStoreInstaller.install(LocationStoreInstaller.java:33)
        在com.triposo.droidguide.rometest.SplashActivity.onStart(SplashActivity.java:58)
        在android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1205)
        在android.app.Activity.performStart(Activity.java:3520)
        在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2373)
        在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
        在android.app.ActivityThread.access $ 2100(ActivityThread.java:116)
        在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1794)
        在android.os.Handler.dispatchMessage(Handler.java:99)
        在android.os.Looper.loop(Looper.java:123)
        在android.app.ActivityThread.main(ActivityThread.java:4203)
        在java.lang.reflect.Method.invokeNative(本机方法)
        在java.lang.reflect.Method.invoke(Method.java:521)
        在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:791)
        在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
        在dalvik.system.NativeStart.main(本机方法)
 

解决方案

我设法解决这个问题到底。如果我使用jarjar重命名com.google.common.io.LineReader到它的工作原理另外一个包的名称(例如com.triposo.vendor.com.google.common.io.LineReader)!我的猜测是,LineReader捆绑在Android中,但略有不同(不兼容)版本。

I'm using the Guava r09 library in an Android app but I'm getting the following error when I use it with 1.6. It's a bit strange because it works fine in 1.5. Also, the method that is "not found" is very clearly there. I also tried including the jsr305.jar file but this still doesn't work.

Appreciate any help, doing I/O in Java is so painful without Guava.

This is the code:

String timestamp = CharStreams.toString(
    CharStreams.newReaderSupplier(timestampFile, Charset.forName("UTF-8")));

This is the exception:

05-08 12:16:41.163: ERROR/dalvikvm(335): Could not find method com.google.common.io.LineReader.<init>, referenced from method com.google.common.io.CharStreams.readFirstLine
05-08 12:16:41.163: WARN/dalvikvm(335): VFY: unable to resolve direct method 6798: Lcom/google/common/io/LineReader;.<init> (Ljava/lang/Readable;)V
05-08 12:16:41.163: WARN/dalvikvm(335): VFY:  rejecting opcode 0x70 at 0x0009
05-08 12:16:41.163: WARN/dalvikvm(335): VFY:  rejected Lcom/google/common/io/CharStreams;.readFirstLine (Lcom/google/common/io/InputSupplier;)Ljava/lang/String;
05-08 12:16:41.163: WARN/dalvikvm(335): Verifier rejected class Lcom/google/common/io/CharStreams;
05-08 12:16:41.163: DEBUG/AndroidRuntime(335): Shutting down VM
05-08 12:16:41.163: WARN/dalvikvm(335): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
05-08 12:16:41.173: ERROR/AndroidRuntime(335): Uncaught handler: thread main exiting due to uncaught exception
05-08 12:16:41.183: ERROR/AndroidRuntime(335): java.lang.VerifyError: com.google.common.io.CharStreams
        at com.triposo.droidguide.rometest.LocationStoreInstaller.install(LocationStoreInstaller.java:33)
        at com.triposo.droidguide.rometest.SplashActivity.onStart(SplashActivity.java:58)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1205)
        at android.app.Activity.performStart(Activity.java:3520)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2373)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
        at android.app.ActivityThread.access$2100(ActivityThread.java:116)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:4203)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:521)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
        at dalvik.system.NativeStart.main(Native Method)

解决方案

I managed to solve this in the end. If I use jarjar to rename com.google.common.io.LineReader to another package name (e.g. com.triposo.vendor.com.google.common.io.LineReader) it works! My guess is that LineReader is bundled in Android but with a slightly different (incompatible) version.

这篇关于使用谷歌番石榴与Android 1.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆