【问题标题】:Unity project after migrating to Android Studio gives this error - java.util.zip.ZipException: duplicate entry: android/support/annotation/Keep.class迁移到 Android Studio 后的 Unity 项目出现此错误 - java.util.zip.ZipException: duplicate entry: android/support/annotation/Keep.class
【发布时间】:2016-04-08 14:57:08
【问题描述】:

我收到以下错误日志:

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

这里是build.gradle 依赖的列表:

dependencies {

    compile project(':chartboostSDK')
    compile project(':flurry_lib')
    compile project(':googleCloudMessaging_lib')
    compile project(':mainLibProj')
    compile project(':localytics_lib')
    compile project(':mobihelp_sdk_android_v1534')
    compile project(':unityandroidresources')
    compile project(':iAB_lib')
    compile project(':etcetera_lib')
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/FlurryPlugin.jar')
    compile files('libs/FreshdeskPlugin.jar')
    compile files('libs/Prime31UnityActivity.jar')
    compile files('libs/adcolony-adapter-1.1.6.jar')
    compile files('libs/android-bridge.jar')
    compile files('libs/apsalar.jar')
    compile files('libs/apsalarUnity3d.jar')
    compile files('libs/bolts-android-1.2.1.jar')
    compile files('libs/chartboost-adapter-1.0.6.jar')
    compile files('libs/crittercism_v5_4_3_sdkonly.jar')
    compile files('libs/dagger.jar')
    compile files('libs/emojiplugin.jar')
    compile files('libs/in-app-purchasing-2.0.61.jar')
    compile files('libs/javax.inject.jar')
    compile files('libs/mediationsdk-6.3.5.jar')
    compile files('libs/nativex-adapter-1.0.3.jar')
    compile files('libs/nineoldandroids.jar')
    compile files('libs/support-annotations-23.1.1.jar')
    compile files('libs/tapjoyconnectlibrary.jar')
    compile files('libs/tapjoyunitywrapper.jar')
    compile files('libs/unity-classes.jar')
    compile files('libs/vungle-adapter-1.1.6.jar')
    compile files('libs/unity-classes.jar')
}

【问题讨论】:

  • 不要放截图,添加实际代码。
  • 添加了实际代码。
  • 解决了你的问题吗?
  • 是的.. 非常感谢您的回答

标签: android unity3d build.gradle


【解决方案1】:

尝试将库作为gradle 依赖项导入,如下所示:

compile 'com.android.support:support-annotations:23.1.1'

如果您想使用jar,那么它似乎没有正确构建。所以尝试做这样的事情:

  1. 解压缩jar 文件。 (只需将.jar 扩展名更改为.zip
  2. 这将删除重复文件。
  3. 使用jar cf xmlbeans.jar -C (path to unzipped folder) . 重新创建jar(注意,命令末尾有一个点)
  4. 使用这个重新生成的jar

【讨论】:

  • 太棒了。乐意效劳。 :)
  • 如果可能的话,你能解释一下它有什么不同吗?
  • gradle 自动从存储库中提取库并正确构建它。如果您包含 jar,则 gradle 不会构建它。在您的情况下,您拥有的 jar 没有正确构建。
猜你喜欢
  • 2016-02-09
  • 2017-08-18
  • 1970-01-01
  • 1970-01-01
  • 2017-09-12
  • 2019-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多