创建apk时出错,仅在创建签名apk时出错

时间:2016-04-29 12:05:31

标签: android android-studio-2.0 android-multidex applovin

我一直在努力解决一个问题,尝试了几个选项,但无法解决它。

只有在创建签名的apk时才会出现问题:

  

错误:任务执行失败   ':应用程序:transformClassesWithJarMergingForDebug'。   com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / applovin / adview / AdViewController.class

Libs结构:http://prntscr.com/ay9uam

依赖结构:

dependencies {
    compile 'com.android.support:multidex:1.0.1'

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile project(':library')
    compile 'com.google.android.gms:play-services:8.4.0'
    //compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.pollfish:pollfish:+:googleplayRelease@aar'

}

注意:我需要添加multiDexEnabled truecompile 'com.android.support:multidex:1.0.1'来解决一个问题,所以我添加了它。 当我这样做时,CMD + O(Mac)搜索AdViewController.class,我得到:http://prntscr.com/ay9uoy

解决问题的下一步应该是什么,应用运行适用于所有情况(在模拟器,设备中运行..),并且只有在生成签名的apk时,我遇到上述问题,这是我的任务的最后一步,我被困住了。

任何回复都对我有利。

2 个答案:

答案 0 :(得分:0)

看起来播放服务已包含support-v4。尝试将其从类路径中排除

compile('com.google.android.gms:play-services:8.1.0') {
exclude group: 'com.android.support', module: 'support-v4'
}

否则你使用这个参考:  TransformException duplicate entry for common.annotations.Beta

答案 1 :(得分:0)

最后我可以解决这个问题。 由于它是applovin类重复,它需要被排除,并且技巧是要做以下事情:

compile fileTree(include: ['*.jar'],excludes: ['applovin-sdk-6.1.5.jar'], dir: 'libs')

希望它有所帮助。