how can I get Picasso and OkHttp to work together? - android

I currently have the following libs added to the classpath (android project, minSDK 16):
Picasso 2.3.3
okhttp 2.0.0
okhttp-urlconnection 2.0.0 RC1
okio 1.0.1
Somehow Picasso refuses to work now and I'm getting the following error message:
VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
VFY: unable to resolve static method 8759: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream;
VFY: replacing opcode 0x71 at 0x000a
VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
VFY: unable to resolve static method 8758: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;
VFY: replacing opcode 0x71 at 0x000a
Could not find method com.squareup.okhttp.OkHttpClient.setInternalCache, referenced from method com.squareup.okhttp.OkUrlFactory.setResponseCache
VFY: unable to resolve virtual method 6548: Lcom/squareup/okhttp/OkHttpClient;.setInternalCache (Lcom/squareup/okhttp/internal/InternalCache;)Lcom/squareup/okhttp/OkHttpClient;
VFY: replacing opcode 0x6e at 0x0009
Could not find method com.squareup.okhttp.OkHttpClient.setConnectTimeout, referenced from method com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.setConnectTimeout
VFY: unable to resolve virtual method 6541: Lcom/squareup/okhttp/OkHttpClient;.setConnectTimeout (JLjava/util/concurrent/TimeUnit;)Lcom/squareup/okhttp/OkHttpClient;
VFY: replacing opcode 0x6e at 0x0005
Could not find method com.squareup.okhttp.OkHttpClient.setReadTimeout, referenced from method com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.setReadTimeout
VFY: unable to resolve virtual method 6553: Lcom/squareup/okhttp/OkHttpClient;.setReadTimeout (JLjava/util/concurrent/TimeUnit;)Lcom/squareu
Is there any way to get those libs to work together?

Use okhttp-urlconnection 2.0.0, not the RC1.

Related

Is it mandatory to include okio if an app wants to use okhttp3?

I have included okhttp3 and tested PATCH and DELETE methods in android versions less than LOLLIPOP (api 21). I did not include Okio and it worked fine. But, in the okhttp site they mention the following:
You'll also need Okio, which OkHttp uses for fast I/O and resizable buffers. Download the latest JAR.
Could anyone please confirm if Okio can be safely ignored to use OkHttp?
Additional info:
I saw the same warning logs with and without okio 1.14.0 in Android 4.1.2 Samsung Galaxy Note while making a PATCH call with OkHttp 3.10.0.
03-02 14:18:39.850 6123-6159/ W/dalvikvm: VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
03-02 14:18:39.850 6123-6159/ W/dalvikvm: VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
03-02 14:18:39.850 6123-6159/ I/dalvikvm: Could not find method java.nio.file.Files.newOutputStream, referenced from method okio.Okio.sink
03-02 14:18:39.855 6123-6159/ W/dalvikvm: VFY: unable to resolve static method 30883: Ljava/nio/file/Files;.newOutputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/OutputStream;
03-02 14:18:39.855 6123-6159/ D/dalvikvm: VFY: replacing opcode 0x71 at 0x000b
03-02 14:18:39.860 6123-6159/ W/dalvikvm: VFY: unable to find class referenced in signature (Ljava/nio/file/Path;)
03-02 14:18:39.865 6123-6159/ W/dalvikvm: VFY: unable to find class referenced in signature ([Ljava/nio/file/OpenOption;)
03-02 14:18:39.865 6123-6159/ I/dalvikvm: Could not find method java.nio.file.Files.newInputStream, referenced from method okio.Okio.source
03-02 14:18:39.865 6123-6159/ W/dalvikvm: VFY: unable to resolve static method 30882: Ljava/nio/file/Files;.newInputStream (Ljava/nio/file/Path;[Ljava/nio/file/OpenOption;)Ljava/io/InputStream;
okio is necessary for okhttp3 to work. However it is included automatically as a transitive dependency. So there is no need to include it explicitly.

Many error messages after updating Gradle plugin for Android to 2.0.0

Since updating Gradle Plugin for Android to 2.0.0, there are many error messages in all projects in Android Studio 2.0.
I would like to know the reason for this and possibly how to avoid it.
This seems not related to the code of my projects, as the errors also show up in an empty or blank project. There are in fact hundreds of lines of warnings and errors, even before first call of onCreate() in a blank project.
This is a small excerpt of the logged errors:
I/dalvikvm: Could not find method android.content.Context.getSystemService, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 450: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x004b
I/dalvikvm: Could not find method android.app.Activity.stopLockTask, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 246: Landroid/app/Activity;.stopLockTask ()V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x00b9
E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve check-cast 229 (Landroid/os/PersistableBundle;) in Lcom/example/test/MainActivity;
D/dalvikvm: VFY: replacing opcode 0x1f at 0x00f1
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 432: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0101
I/dalvikvm: Could not find method android.app.Activity.onVisibleBehindCanceled, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 169: Landroid/app/Activity;.onVisibleBehindCanceled ()V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0111
I/dalvikvm: Could not find method android.app.Activity.onWindowStartingActionMode, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 173: Landroid/app/Activity;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0137
E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve check-cast 229 (Landroid/os/PersistableBundle;) in Lcom/example/test/MainActivity;
D/dalvikvm: VFY: replacing opcode 0x1f at 0x019a
E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.test.MainActivity.access$super
With Gradle Plugin 1.5.0 everything went fine.
With Gradle Plugin 2.0.0 these errors come up.
I updated to 2.0.0, because Android Studio 2.0 recommends the update:
The project is using an old version of the Android Gradle plugin. To
take advantage of all the latest features, such as Instant Run, we
strongly recommend that you update the Android Gradle plugin to
version 2.0.0.
As there are hundreds of lines of errors at the start of any app and many more later, this makes using logcat for debugging extremely difficult.
I have tried to downgrade to 1.5.0 as described in this answer. This does actually prevent the errors to come up. Anyhow, I do not regard this as a solution, but rather a work-around, as I cannot use the new features of plugin 2.0.0.
Yes, unfortunately, the Android team decided to use the INFO rather than VERBOSE tag on these messages:
https://code.google.com/p/android/issues/detail?id=198567
The solution is to create a custom filter. Give it a [Filter Name]. Click [Edit Filter Configuration] on the right of the Android Monitor window toolbar. In the [Log Tag], enter "^(?!(dalvikvm))", minus the quotes, and make sure [Regex] is Checked next to it. In the [Package Name] field, enter your top-level package name (e.g. com.example.me). Select Debug for [Log Level] and click [OK]. Finally make sure to select your new filter back in the toolbar.

What do these Android logcat warnings mean?

It doesn't seem to impact anything in my app... yet. I'm using the Android support libraries for the first time (my projects to date have not used support libraries), but this is a new project without much in the way of customization yet. Activities were generated by Android Studio 0.9.2 and implement Navigation Drawer.
Running this on a Verizon Samsung Galaxy SIII running Android 4.4.2. Project is set to minSDK of 15 and targeted SDK of 21.
11-21 10:31:18.204 7095-7095/com.myapp.debug I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
11-21 10:31:18.204 7095-7095/com.myapp.debug W/dalvikvm﹕ VFY: unable to resolve virtual method 11400: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
11-21 10:31:18.204 7095-7095/com.myapp.debug D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
11-21 10:31:18.204 7095-7095/com.myapp.debug I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
11-21 10:31:18.204 7095-7095/com.myapp.debug W/dalvikvm﹕ VFY: unable to resolve virtual method 11406: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
11-21 10:31:18.204 7095-7095/com.myapp.debug D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
11-21 10:31:18.204 7095-7095/com.myapp.debug I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
11-21 10:31:18.204 7095-7095/com.myapp.debug W/dalvikvm﹕ VFY: unable to resolve virtual method 8977: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
11-21 10:31:18.204 7095-7095/com.myapp.debug D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
11-21 10:31:18.234 7095-7095/com.myapp.debug I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
11-21 10:31:18.234 7095-7095/com.myapp.debug W/dalvikvm﹕ VFY: unable to resolve virtual method 368: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
11-21 10:31:18.234 7095-7095/com.myapp.debug D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
11-21 10:31:18.234 7095-7095/com.myapp.debug I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
11-21 10:31:18.234 7095-7095/com.myapp.debug W/dalvikvm﹕ VFY: unable to resolve virtual method 390: Landroid/content/res/TypedArray;.getType (I)I
11-21 10:31:18.234 7095-7095/com.myapp.debug D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
If I'm guessing (and I am), I'm missing a library that android.support.v7 requires. But I have no idea what or where to find it.
I would like to add on top of what #Monte Creasor explained.
I have had the same issue and consulted this bug report which basically says that the problem might be caused by com.android.support:appcompat-v7:21.0.3, on of the main dependencies required to use Android's new Layout capabilities.
Try going back to the v7:20.0.0, this should solve the issue as it did for me and this bug report writer.
Actually all you have to change is in the app build.gradle the line:
compile 'com.android.support:appcompat-v7:21.0.3' or whatever later version you have
to
compile 'com.android.support:appcompat-v7:20.0.0'
These errors occur when you run android studio 1.0 using the sliding drawer sample WITHOUT adding any additional code and using all the defaults the project creation wizard offers. So it would seem to be an Android Studio problem and not a developer coding error.
I had the same issue, also I wasn't able to get my ListFragment scrollable. Used v4 support library 21.0.3 before and upgraded to 22.0.0.
This fixed my problems!
I'm currently going through my logs generated from using Sony's remote device lab, the same warning appears so it's not a Android Studio problem. I suspect its a problem with the ActionBar theme used during the development of the application.

Could not find method getAccessibilityNodeProvider

I am using the number selector simonvt library (https://github.com/SimonVT/android-numberpicker).
I added the library successfully and the application runs normally, but the LogCat is showing these warnings:
Could not find method android.widget.LinearLayout.getAccessibilityNodeProvider, referenced from method net.simonvt.numberpicker.NumberPicker.getAccessibilityNodeProvider
The complete log:
10-08 18:13:36.152: I/dalvikvm(489): Could not find method android.widget.LinearLayout.getAccessibilityNodeProvider, referenced from method net.simonvt.numberpicker.NumberPicker.getAccessibilityNodeProvider
10-08 18:13:36.152: W/dalvikvm(489): VFY: unable to resolve virtual method 5439: Landroid/widget/LinearLayout;.getAccessibilityNodeProvider ()Landroid/view/accessibility/AccessibilityNodeProvider;
10-08 18:13:36.162: D/dalvikvm(489): VFY: replacing opcode 0x6f at 0x0004
10-08 18:13:36.172: W/dalvikvm(489): Unable to resolve superclass of Lnet/simonvt/numberpicker/NumberPicker$AccessibilityNodeProviderImpl; (701)
10-08 18:13:36.182: W/dalvikvm(489): Link of class 'Lnet/simonvt/numberpicker/NumberPicker$AccessibilityNodeProviderImpl;' failed
10-08 18:13:36.192: W/dalvikvm(489): VFY: unable to find class referenced in signature (Landroid/view/accessibility/AccessibilityNodeProvider;)
10-08 18:13:36.192: D/dalvikvm(489): VFY: dead code 0x0007-0007 in Lnet/simonvt/numberpicker/NumberPicker;.getAccessibilityNodeProvider ()Landroid/view/accessibility/AccessibilityNodeProvider;
10-08 18:13:36.212: I/dalvikvm(489): Could not find method android.widget.LinearLayout.onInitializeAccessibilityEvent, referenced from method net.simonvt.numberpicker.NumberPicker.onInitializeAccessibilityEvent
10-08 18:13:36.212: W/dalvikvm(489): VFY: unable to resolve virtual method 5449: Landroid/widget/LinearLayout;.onInitializeAccessibilityEvent (Landroid/view/accessibility/AccessibilityEvent;)V
10-08 18:13:36.232: D/dalvikvm(489): VFY: replacing opcode 0x6f at 0x0000
10-08 18:13:36.232: D/dalvikvm(489): VFY: dead code 0x0003-0026 in Lnet/simonvt/numberpicker/NumberPicker;.onInitializeAccessibilityEvent (Landroid/view/accessibility/AccessibilityEvent;)V
The sample project shows these warnings too!
Thank you
What device are you running this on? The method android.widget.LinearLayout.getAccessibilityNodeProvider was added in API level 16 (Jelly Bean 4.1) according to the docs. So it won't work on Ice Cream Sandwich or lower devices. Try the simulator to see if that works.

Why is android.util.LruCache.* not found when using android-support-v4?

I am writing a project that uses LruCache, which is included in the android-support-v4.jar compat library. When running on devices with JB, the code works fine, but when I run it on my Droid X with GB, the app dies with the following errors:
I/dalvikvm(2459): Could not find method android.util.LruCache.put, referenced from method blah.blah.Utility.getBitmap
W/dalvikvm(2459): VFY: unable to resolve virtual method 2641: Landroid/util/LruCache;.put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(2459): VFY: replacing opcode 0x6e at 0x0026
... [repeats similar lines] ...
W/dalvikvm(2459): Unable to resolve superclass of Lblah/blah/Utility$1; (353)
W/dalvikvm(2459): Link of class 'Lblah/blah/Utility$1;' failed
E/dalvikvm(2459): Could not find class 'blah.blah.Utility$1', referenced from method blah.blah.Utility.initCaches
W/dalvikvm(2459): VFY: unable to resolve new-instance 559 (Lblah/blah/Utility$1;) in Lblah/blah/Utility;
D/dalvikvm(2459): VFY: replacing opcode 0x22 at 0x000d
D/dalvikvm(2459): VFY: dead code 0x000f-002c in Lblah/blah/Utility;.initCaches (ILandroid/content/Context;)V
I/dalvikvm(2459): Could not find method android.util.LruCache.get, referenced from method blah.blah.Utility.mCacheGet
W/dalvikvm(2459): VFY: unable to resolve virtual method 2640: Landroid/util/LruCache;.get (Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(2459): VFY: replacing opcode 0x6e at 0x0008
D/dalvikvm(2459): VFY: dead code 0x000b-000e in Lblah/blah/Utility;.mCacheGet (Ljava/lang/String;)Landroid/graphics/Bitmap;
... [repeats similar lines] ...
D/AndroidRuntime(2459): Shutting down VM
W/dalvikvm(2459): threadid=1: thread exiting with uncaught exception (group=0x40018560)
E/AndroidRuntime(2459): FATAL EXCEPTION: main
E/AndroidRuntime(2459): java.lang.NoClassDefFoundError: blah.blah.Utility$1
E/AndroidRuntime(2459): at blah.blah.Utility.initCaches(Utility.java:49)
E/AndroidRuntime(2459): at blah.blah.MainActivity.onCreate(MainActivity.java:40)
... [etc] ...
W/ActivityManager(1318): Force finishing activity blah.blah/.MainActivity
Utility.java:49 looks like this:
mCache = new LruCache<String, Bitmap>( mCacheSize ) // <-- line 49 --
{
#Override
protected int sizeOf( String key, Bitmap bitmap )
{
return bitmap.getByteCount();
}
};
So everywhere I referenced LruCache or its methods causes an error. The first thing that comes to mind is that android-support-v4.jar was somehow left out of the APK file, but that doesn't look like the case. I've placed the jar file under libs/, and checking classes.dex.d after running ant debug, I see that it has added the following line:
/home/paul/workspace/blah/libs/android-support-v4.jar \
My second thought was that maybe LruCache isn't in android-support-v4, but looking at the source I see that the following source file is in there, and that it has the methods I am trying to use:
/home/paul/bin/android-sdk/extras/android/support/v4/src/java/android/support/v4/util/LruCache.java
So why isn't it found?
The classes in the support library use a different namespace.
You need to import:
import android.support.v4.util.LruCache;
or alternatively you can copy & compile LruCache.java directly into your app.

Categories

Resources