虽然我已阅读过类似的问题并试图应用此代码:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
在我的app build.gradle中,我仍然遇到同样的错误。
logcat中的错误消息:
Error:Execution failed for task ':kalturaClient:transformResourcesWithMergeJavaResForRelease'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE.txt
File1: /home/teo/Documents/AndroidStudioWorkspace/Kaltura/DemoApplication/kalturaClient/libs/commons-codec-1.4.jar
File2: /home/teo/Documents/AndroidStudioWorkspace/Kaltura/DemoApplication/kalturaClient/libs/commons-httpclient-3.1.jar
我也尝试过清理项目,但没有运气。 我正在使用Android Studio 1.5.1
我的build.gradle文件是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.kaltura.activity"
minSdkVersion 8
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile project(':kalturaClient')
compile 'com.android.support:support-v4:23.0.1'
compile files('libs/WidevineDRM-Debug-5.0.0.12188.jar')
compile files('libs/apksigtool.jar')
compile files('libs/commons-codec-1.4.jar')
compile files('libs/commons-httpclient-3.1.jar')
compile files('libs/simple-social-sharing-1.0.0.jar')
compile files('libs/universal-image-loader-1.2.1.jar')
}
答案 0 :(得分:4)
你应该添加
android {
// Fixed build error : Duplicate files copied in APK META-INF/LICENSE.txt
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}
更多详情您可以访问 Android Studio 0.4 Duplicate files copied in APK META-INF/LICENSE.txt
答案 1 :(得分:1)
试试这个。
packagingOptions {
pickFirst 'META-INF/NOTICE.txt'
pickFirst 'META-INF/DEPENDENCIES.txt'
pickFirst 'META-INF/LICENSE.txt'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
希望它会对你有所帮助。