android - 如何修复 "Execution failed for task ‘:app-guest:transformClassesWithJarMergingForProductionRelease’。”

标签 android google-maps google-play-services google-places google-places-autocomplete

所以问题是谷歌更新了 places SDK 并将它们与谷歌播放服务分开。现在,当我更新 places sdk 并添加:"com.google.android.libraries.places:places-compat:1.1.0"

这是谷歌在迁移指南中给出的

https://developers.google.com/places/android-sdk/client-migration

我做了一些改动,能够编译运行成功。

但是当我尝试为此创建一个发布 apk 时,它给了我这个:

    What went wrong:
    Execution failed for task ‘:app-guest:transformClassesWithJarMergingForProductionRelease’.
    > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/INotificationSideChannel$Stub$Proxy.class.

我认为有一些库已经包含在播放服务中,并且正在被新的 places sdk 依赖项重复。

我已经尝试过通过终端检查依赖关系的命令。

播放我在我的应用中使用的服务

    val plus = artifact(artifactId = "play-services-plus")
    val auth = artifact(artifactId = "play-services-auth")
    val base = artifact(artifactId = "play-services-base")
    val analytics = artifact(artifactId = "play-services-analytics")
    val cast = artifact(artifactId = "play-services-cast")
    val gcm = artifact(artifactId = "play-services-gcm")
    val location = artifact(artifactId = "play-services-location")
    val maps = artifact(artifactId = "play-services-maps",version = "16.1.0")
    val nearby = artifact(artifactId = "play-services-nearby")
    val safetynet = artifact(artifactId = "play-services-safetynet")
    val wallet = artifact(artifactId = "play-services-wallet")
    val tasks = artifact(artifactId = "play-services-tasks")

支持图书馆我就是我们

 // v4 support libraries
    val support_compat = artifact("support-compat")
    val support_core_utils = artifact("support-core-utils")
    val support_core_ui = artifact("support-core-ui")
    val support_media_compat = artifact("support-media-compat")
    val support_fragment = artifact("support-fragment")
    @Deprecated("Prior to Support Library revision 24.2.0, there was a single v4 support library. That library was divided into multiple modules to improve efficiency. For backwards compatibility, if you list support-v4 in your Gradle script, your APK will include all of the v4 modules. However, to reduce APK size, we recommend that you just list the specific modules your app needs.")
    val support_v4 = artifact("support-v4")

    // Multidex Support Library
    /** Multidex - See: https://developer.android.com/studio/build/multidex.html */
    val multidex = artifact("multidex", version = Versions.multidex)
    val multidex_instrumentation = artifact("multidex-instrumentation", Versions.multidex)

    // v7 Support Libraries
    val appcompat_v7 = artifact("appcompat-v7")
    val cardview_v7 = artifact("cardview-v7")
    val gridlayout_v7 = artifact("gridlayout-v7")
    val mediarouter_v7 = artifact("mediarouter-v7")
    val palette_v7 = artifact("palette-v7")
    val recyclerview_v7 = artifact("recyclerview-v7")
    val preference_v7 = artifact("preference-v7")

    val support_v13 = artifact("support-v13")
    val preference_v14 = artifact("preference-v14")
    val preference_leanback_v17 = artifact("preference-leanback-v17")
    val leanback_v17 = artifact("leanback-v17")
    val support_vector_drawable = artifact("support-vector-drawable")
    val animated_vector_drawable = artifact("animated-vector-drawable")
    val support_annotations = artifact("support-annotations")
    val design = artifact("design")
    val customtabs = artifact("customtabs")
    @Deprecated("As of release 26.0.0, the Percent Support library is deprecated. Clients of this module should migrate to the new ConstraintLayout widget, which is provided as a separate artifact in SDK Manager.")
    val percent = artifact("percent")
    val exifinterface = artifact("exifinterface")
    val recommendation = artifact("recommendation")
    val wear = artifact("wear")

    val constraint_layout = artifact("constraint-layout", Versions.constraintlayout, ".constraint")

谁能告诉我哪个库正在使用这个“INotificationSideChannel”,以便我可以排除它。

最佳答案

您不得在您的应用或依赖项中重复库。你必须检查你是否插入了v4库和编译库?

删除重复库,只剩下一个V4。

在您的应用程序目录 build.gradle 文件中添加此命令:

android{


    configurations {
        all*.exclude group: 'com.android.support', module: 'support-v4'
        all*.exclude group: 'com.android.support', module: 'support-annotations'
    }

}

关于android - 如何修复 "Execution failed for task ‘:app-guest:transformClassesWithJarMergingForProductionRelease’。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57001516/

相关文章:

ruby-on-rails - 如何从 rails 中的谷歌地图中选择坐标?

javascript - 如何使 map 集群在 map 中密度较低的区域中距离更大而不是显示标记

android - 为什么 Google 建议将库复制到您的树中?

android - 更新到 Google Play 服务 11.8.0 后 Proguard 不工作

android - appcompat-v7 :25. 2.0 与播放服务 :10. 2.1 冲突

Android Tumblr oAuth 混淆

android - 无法启动 AVD 和 SDK 管理器 (Android Studio 0.2.1)

android - 在 Junit for Android 中使用 FEST-assert 的正确方法?

android - 滑动菜单栏覆盖 ViewPager 选项卡。如何阻止这种情况发生?

javascript - Angular 2 : Multiple included error