【问题标题】:duplicated class caused by mulitedex dependecy in Android StudioAndroid Studio中multidex依赖导致的重复类
【发布时间】:2017-05-13 01:34:51
【问题描述】:

感谢您的支持。 我的问题是:当我添加 multidex 依赖项并尝试导出已签名的 apk 时,我收到此错误:

错误:任务执行失败 ':androidKeyboardThemes:transformClassesWithJarMergingForRelease'.

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/android/gms/location/ActivityRecognition$1.class

我的 gradle 依赖是论文:

 dependencies {
    compile project(':cropper')
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/StartAppInApp-2.4.7.jar')
    compile files('libs/google-play-services.jar')
    compile 'com.android.support:multidex:1.0.1'
}

我试图随时删除一个 lib 或 jar 并重新构建,但我无法完成工作。 此外,我还阅读了有关 stackoverflow 中重复类的所有内容,但我再次未能解决我的问题。 有什么想法吗?谢谢你的帮助。

【问题讨论】:

    标签: android class signed android-multidex


    【解决方案1】:
    dependencies {
    compile project(':cropper')
    compile 'com.google.android.gms:play-services:+'   <-- choose either one
    compile files('libs/StartAppInApp-2.4.7.jar')
    compile files('libs/google-play-services.jar')     <-- choose either one
    compile 'com.android.support:multidex:1.0.1' 
    }
    

    无论是什么,请不要使用播放服务。里面 compile 'com.google.android.gms:play-services:+' 包含很多依赖项.. 见下文.. 使用 play-services 可能会导致 dex 问题和繁重的应用程序。参考here

    【讨论】:

    • 感谢您的回复;它适用于:gradle: dependencies { compile project(':cropper') compile 'com.google.android.gms:play-services-plus:10.2.1' // All of them except pay, map and location compile 'com.google.android.gms:play-services-games:10.2.1' compile files('libs/StartAppInApp-2.4.7.jar') //compile files('libs/google-play-services.jar') compile 'com.android.support:multidex:1.0.1 } 但是当我测试 APK 以将其安装到我的设备上时,仍然需要 85 秒。任何主要问题都已解决,谢谢@Saurabh 和@ZeroOne。
    猜你喜欢
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 2021-07-14
    • 2023-03-21
    • 2014-07-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多