Search code examples
javaandroidgradlecompiler-errorsandroid-multidex

Missing gms.maps.GoogleMap Because of Potential Multi-Dex Issue Results In Duplicate Class


I am adding a GoogleMap view to my project.

From my research I needed to add:

compile 'com.google.android.gms:play-services-maps:8.1.0'

To my build dependencies (without that I cannot import import com.google.android.gms.maps.OnMapReadyCallback).

So when I add that dependency, all is well in the class, I can import it and use it.

Then I went to compile and I got a nasty error:

Error:Execution failed for task finished with non-zero exit value 2

After research I determined that this meant I was now over the 65k method limit.

So fast forward and I add multi-dex support to my app. Now I have a new error and cannot figure out the solution.

Execution failed for task ':packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/SignInButton.class

It clearly is saying there is a collision of 2 classes having the same name. But what I don't understand is how that is possible. Here is my compile dependencies. I don't see any duplicate imports or potential collisions. Can you advise me where else to look for that might be causing this collision?

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services-maps:8.1.0'
    compile 'com.android.support:multidex:1.0.1'
    compile project(':CordovaLib')
    compile project(':app-FacebookLib')
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile files('libs/twitter4j-core-4.0.4-SNAPSHOT.jar')
}

Solution

  • There was a google-play-services.jar file added to the library folder in my project that was colliding with this. Removing that jar fixed it.

    I found the duplicate from this answer

    https://stackoverflow.com/a/28937822/3324388