Search code examples
androidgradleapkgoogle-maps-api-2

Error generating signed apk with android map utils library


Since I added this dependency I cannot generate a signed APK anymore. Weirdly, Build/Build APK works, but Build/Generate signed APK fails with these lines:

Warning:com.google.maps.android.clustering.ClusterManager: can't find superclass or interface com.google.android.gms.maps.GoogleMap$OnCameraIdleListener
Warning:com.google.maps.android.clustering.ClusterManager: can't find referenced class com.google.android.gms.maps.GoogleMap$OnCameraIdleListener
Warning:com.google.maps.android.kml.KmlRenderer: can't find referenced method 'void setZIndex(float)' in program class com.google.android.gms.maps.model.Marker
Warning:there were 4 unresolved references to classes or interfaces.
Warning:there were 1 unresolved references to program class members.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:java.lang.RuntimeException: java.io.IOException: Please correct the above warnings first.
Error:java.io.IOException: Please correct the above warnings first.
Information:BUILD FAILED

Here is my module build.gradle dependency part:

apply plugin: 'com.android.model.library'
apply plugin: 'com.google.gms.google-services'

dependencies {
    compile 'com.google.android.gms:play-services-maps:9.0.2'
    compile 'com.google.maps.android:android-maps-utils:0.4+'
}

model
{
    [etc...]
}

And this is the project level one:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.8.0'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Solution

  • it may be Proguard (which is doing its work) when you try to generate the signed apk(release version), you may solve this by adding

    -keep public class com.google.android.gms.* { public *; }
    -dontwarn com.google.android.gms.**
    

    But normally this is already done in the maps library, i would recommend using the latest version the maps lib before You try the above solution

    com.google.android.gms:play-services-maps:9.8.0