由于我添加了此依赖项,因此我无法再生成签名的 APK。奇怪的是,构建/构建 APK 可以工作,但是构建/生成签名的 APK 失败并出现以下几行:
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
这是我的模块 build.gradle 依赖部分:
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...]
}
这是项目一级:
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
}
}
最佳答案
当您尝试生成已签名的 apk(发布版本)时,它可能是 Proguard(正在执行其工作),您可以通过添加来解决此问题
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
但通常这已经在 map 库中完成,我建议在您尝试上述解决方案之前使用最新版本的 map 库
com.google.android.gms:play-services-maps:9.8.0
关于android - 使用 android map utils library 生成签名 apk 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40289405/