【问题标题】:How to exclude LICENSE files in sbt-android-sdk plugin?如何在 sbt-android-sdk 插件中排除 LICENSE 文件?
【发布时间】:2014-07-09 16:16:39
【问题描述】:

我正在使用 https://github.com/pfn/android-sdk-plugin 使用 Scala 构建我的 Android 应用程序。当我运行sbt android:package 时,我得到了这个错误:

com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
    File 1: ...ivy2\cache\org.apache.httpcomponents\httpcore\jars\httpcore-4.0.1.jar
    File 2: ...ivy2\cache\org.apache.httpcomponents\httpcore\jars\httpcore-4.0.1.jar

我搜索了一段时间,有人说我可以设置packageOptions 来排除许可证。但我是 Scala 新手,不知道该怎么做。

【问题讨论】:

  • 你能提供你的build.sbt吗?

标签: android scala sbt


【解决方案1】:
apkbuildExcludes in Android += "META-INF/LICENSE.txt"

在你的情况下是“META-INF/LICENSE”。

https://github.com/pfn/android-sdk-plugin

查看新功能部分。

【讨论】:

  • 这为我修复了 - 请注意这只是在您的主 bu​​ild.sbt 中。我还发现 NOTICE.txt 文件有问题,所以我使用了:apkbuildExcludes in Android ++= Seq("META-INF/LICENSE.txt", "META-INF/NOTICE.txt")
  • 在最新版本的android scala 插件中。 apkbuildExcludes 键已弃用,packingOptions 用于排除。 packagingOptions in Android := PackagingOptions( Seq.empty[String], Seq( "META-INF/LICENSE", "META-INF/LICENSE.txt", "META-INF/NOTICE", "META-INF/NOTICE.txt"), Seq.empty[String])
  • 在最新版本的android scala 插件中。 apkbuildExcludes 键已弃用,packingOptions 用于排除。 packagingOptions in Android := PackagingOptions(Seq( "META-INF/LICENSE", "META-INF/LICENSE.txt", "META-INF/NOTICE", "META-INF/NOTICE.txt"))
【解决方案2】:

https://code.google.com/p/android/issues/detail?id=61573#c14 的一个技巧解决了我的问题:

find .../path/to/package/caches/ -iname "*.jar" -exec zip -d '{}' 'META-INF/*' \;

gradle 他们有:

android {
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }
}

可能是插件可以做packageOptions in Adroid += exclude("...")?由于我已经应用了这个技巧,我无法再验证这个想法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-31
    • 2013-12-21
    • 2014-05-10
    • 1970-01-01
    • 1970-01-01
    • 2016-02-01
    • 2017-12-16
    • 2012-01-31
    相关资源
    最近更新 更多