java Android Studio 外部 jar 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33888596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio external jar Error
提问by Jossy Joy
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithJarMergingForDebug UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:transformClassesWithMultidexlistForDebug UP-TO-DATE
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/license.txt File1: C:\Users\system2\AndroidStudioProjects\PorjectName\app\libs\spring-android-rest-template-2.0.0.M1.jar File2: C:\Users\system2\AndroidStudioProjects\ProjectName\app\libs\spring-android-core-2.0.0.M1.jar
回答by Faezeh
This question is duplicate. For resolve it you must add
这个问题是重复的。要解决它,您必须添加
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
in build.gradle
在 build.gradle 中
回答by Rabin Pantha
I faced the same problem and I adopted the above mentioned logic ie. adding
我遇到了同样的问题,我采用了上面提到的逻辑,即。添加
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
in build.gradle ... But it didn't work for me and I added the following code that eventually worked... Adding the following code in build.gradle
在 build.gradle 中......但它对我不起作用,我添加了以下最终有效的代码......在 build.gradle 中添加以下代码
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
回答by ChrisR
I also faced this same problem. Some files have the ".txt" and some do not. If you keep adding one exclude
at a time and run your app, you will see in the "Messages Gradle Build" window all the files needed to exclude
in your project. All I needed was this code and it solved my problem.
我也遇到了同样的问题。有些文件有“.txt”,有些没有。如果您exclude
一次添加一个并运行您的应用程序,您将在“Messages Gradle Build”窗口中看到exclude
项目中所需的所有文件。我所需要的只是这段代码,它解决了我的问题。
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
回答by Juan Pablo
I faced the same issue. I added this code:
我遇到了同样的问题。我添加了这个代码:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
inside my build.gradle Module:app into the section android{}
在我的 build.gradle Module:app 中进入 android{} 部分
At the end, my adroid section on build.gradle. Module app is:
最后,我在 build.gradle 上的 adroid 部分。模块应用程序是:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}