3

Our app uses latest version of OkHttp (2.0.0) + Okio (1.0.0) + Picasso (2.3.2) and I wanted to try it out on the new "Android L" emulator (Intel) and it gets installed but when loading the app i get this:

06-27 09:47:16.214: E/AndroidRuntime(2815): FATAL EXCEPTION: main
06-27 09:47:16.214: E/AndroidRuntime(2815): java.lang.NoSuchMethodError: No static method source(Ljava/io/File;)Lokio/Source; in class Lokio/Okio; or its super classes (declaration of 'okio.Okio' appears in /system/framework/okhttp.jar)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at   com.squareup.okhttp.internal.DiskLruCache.readJournal(DiskLruCache.java:243)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.okhttp.internal.DiskLruCache.open(DiskLruCache.java:224)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.okhttp.Cache.<init>(Cache.java:146)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:74)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:51)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.picasso.OkHttpDownloader.<init>(OkHttpDownloader.java:41)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.picasso.Utils$OkHttpLoaderCreator.create(Utils.java:407)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.picasso.Utils.createDefaultDownloader(Utils.java:255)
06-27 09:47:16.214: E/AndroidRuntime(2815):     at com.squareup.picasso.Picasso$Builder.build(Picasso.java:596)

It comes from the creation of the Picasso object with Picasso.with(Context). Note that the same code, without any change works great on the previous emulator 4.4.2 (Intel).

I don't understand where this (declaration of 'okio.Okio' appears in /system/framework/okhttp.jar) is coming from.

UPDATE

I'm using Eclipse Luna with the latest Android SDK tools..I also tried to select the OkHttp jars in the Order/Export and the error persists..

I used the DDMS File Explorer and i found a okhttp.jar (309 bytes) in the path /system/framework/okhttp.jar of the emulator. Maybe this is causing the problem, but why wouldn't it lookup my own okhttp.jar provided in the APK?

I temporarily uploaded the referred 'okhttp.jar' file to this link: http://www.filedropper.com/okhttp

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Alécio Carvalho
  • 13,481
  • 5
  • 68
  • 74

1 Answers1

6

The L preview release has improperly packaged Okio. This has already been fixes in AOSP master for the next release of the preview.

See https://github.com/square/okhttp/issues/967 for workarounds which include using Proguard to repackage Okio in your own app.

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • Maybe there is an easier way to do this but here is my workaround build.gradle file. https://gist.github.com/bbergler/5f1b2219e4edcd1a836b – Bernd Jun 30 '14 at 13:59