Reputation: 4990
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)
Upvotes: 8
Views: 5776
Reputation: 4990
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.
Upvotes: 5
Reputation: 77752
This is why using undocumented Android API calls is bad. CharStreams was never part of the Android API (you don't see its removal being mentioned in the 1.6 changelog).
Undocumented classes or methods could disappear without notice from any OS revision, like it happened here.
Upvotes: 1