Kostas Kostas - 3 months ago 28
Android Question

Google Play services and WebView strange interaction

I have an app which uses Vision API from Google, and has a WebView which shows some internet content.
When the build.gradle file contains this line:

compile 'com.google.android.gms:play-services:8+'
everything compiles and work ok.

I want to use the latest version, so I change it to:

compile 'com.google.android.gms:play-services:9.6.1'

Then I hit the limit of 64K method references in a .dex file
Using multidex library and changing my manifest file, doesn't solve it.

So I tried the granular approach, and changed the line to:

compile 'com.google.android.gms:play-services-vision:9.6.1'

Then it compiles ok, but when running, every attempt to load a url in WebView,
fails and onReceivedError is called with errorCode -1.

I don't know if it is important, but the actual use of WebView, is done from a library which has nothing to do with Play Services.

Can somebody propose something?
Thank you


Then I hit the limit of 64K method references in a .dex file

Because it contains more than 56k methods.

com.google.android.gms:play-services-vision:9.6.1 is for Mobile Vision.

I can help you with getting over the 64 method limit though, do the steps below

But first make sure you have permission

<uses-permission android:name="android.permission.INTERNET" />

and active internet connection.

First put this in your buidl.gradle

dependencies {
    compile 'com.android.support:multidex:1.0.1'

then put multiDexEnabled true

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 24

        // Enabling multidex support.
        multiDexEnabled true


Then go to your menifest and in your application tag


I hope it will resolve your problem.