Coding⏱️ 3 min read📅 2026-06-04

How to Fix: Error :: duplicate files during packaging of APK

Duplicate files in APK packaging error solution.

Quick Answer: Exclude unnecessary files from the APK using the 'packagingOptions' block in your build.gradle file.

Error: Duplicate files during packaging of APK is an issue that affects Android developers who use Android Studio to build and package their applications. This error occurs when the application's assets, such as images, fonts, or other media files, are not properly configured, causing duplicate copies of these files to be included in the APK file.

This error can be frustrating because it prevents the application from being installed on a device, resulting in an error message that displays the duplicate file issue. However, with the following steps, you should be able to resolve this issue and successfully build and package your Android application.

⚠️ Common Causes

  • The primary cause of this error is the incorrect configuration of the application's assets in the `build.gradle` file. Specifically, the `packagingOptions` section needs to be configured correctly to exclude unnecessary files from being included in the APK.
  • Another possible cause is the presence of duplicate files within the application's assets folder. This can occur when files are renamed or duplicated accidentally during development.

🚀 How to Resolve This Issue

Configuring the packagingOptions section

  1. Step 1: Open the `build.gradle` file and navigate to the `packagingOptions` section.
  2. Step 2: Add the following lines of code to exclude unnecessary files from being included in the APK: `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'`.
  3. Step 3: Save the changes to the `build.gradle` file and rebuild the application using Android Studio.

Resolving duplicate files

  1. Step 1: Locate the source of the duplicate file issue by checking the application's assets folder. Look for any files that are being renamed or duplicated accidentally during development.
  2. Step 2: Rename or delete the duplicate file to resolve the issue. If necessary, remove any unnecessary files from the application's assets folder.

💡 Conclusion

By following these steps, you should be able to resolve the Error: Duplicate files during packaging of APK issue in Android Studio. Remember to configure the `packagingOptions` section correctly and eliminate duplicate files within your application's assets folder to prevent this error from occurring in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions