Android studio error Error:Execution failed for task
Recently, when doing the face recognition check-in system based on Android platform, after importing the third party’s lib package, Android studio reported the following error:
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
File1: E:\Workspaces\Swface\app\libs\httpcore-4.4.4.jar
File2: E:\Workspaces\Swface\app\libs\httpclient-4.5.2.jar
After consulting the data, it is found that there are duplicate contents loaded in the meta-inf directory of the jar package. Open the corresponding jar package
sure enough, both of the two jar packages have license, and further Click to find that the contents are exactly the same. However, it seems that the next three files are also duplicate (only there is no clear prompt in the error report), so we can solve them all at once
all Now that we know that it is caused by repeatedly loading files, the solution is to remove the repeatedly loaded files during compilation. The specific operations are as follows:
-
- Open app\ build.gradle File
-
- 2. Modify the configuration as follows:
buildTypes {
...... (omit part of the code)
// Add the following code here
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/notice.txt'
}
}
``
3. Rebuild project
A link to the original text is attached
Read More:
- [Solved] Android Studio Compile Error: Execution failed for task ‘:APP_MIDI:lintVitalRelease‘.
- [Solved] Android app development version update failed, Android – error: task execution failed ‘: app: com
- [Solved] Android Studio Error: Error:Execution failed for task’:app:mergeDebugResources’
- [Solved] Android Error: Execution failed for task ‘:app:mergeReleaseNativeLibs‘.
- [Solved] Execution failed for task ‘:app:mergeDebugJavaResource‘.
- [Solved] Execution failed for task ‘:app:checkDebugAarMetadata‘
- Execution failed for task ‘:app:kaptDebugKotlin‘ [How to Solve]
- [Solved] Execution failed for task ‘:app:processDebugResources‘. > A failure occurred while executing com.and
- Execution failed for task ‘:app:processDebugMainManifest‘.> Manifest merger failed : Apps targeting
- [Solved] Cordova Android Compile Error: Execution failed for task ‘:packageDebug‘
- [How to Solve] Task :app:compileDebugKotlin FAILED
- [Solved] AndroidStudio package Invalid keystore format Error: Execution failed for task ‘:examplecases:packageRelease’…
- Springboot Compile Error: Execution failed for task ‘:buildSrc:checkFormatMain‘
- [Solved] UE4 Android Package Error: failed for task :permission_library:compileDebugJavaWithJavac
- Android7.0+ Failed to Share Images: exposed beyond app through ClipData.Item.getUri()
- [Solved] Failed to apply plugin appears when Android studio imports a project
- [Solved] Android Studio Start Error: Missing essential plugin: org.jetbrains.android Please reinstall Android
- Android Studio: Gradle project sync failed [How to Solve]
- [Solved] :app:processDebugResources Android resource linking failed Android resource linking failed
- [Solved] Android-android studio apk Install Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED