Android – Fix for Duplicate files copied in APK

If you are an android developer you may already familiar with this issue.

Usually you’re getting this for some text files or license files like  META-INF/notice.txt ,  META-INF/license.txt ,  META-INF/ASL2.0

In such scenarios we can exclude those files from APK packaging without any hesitation because we definitely know those will not affect our application functionality. We can do so using gradle  packagingOptions .

What can we do when we get like

or

or

We cannot exclude those files since they required for app functionality. So we need another way to handle such scenarios.

We can use  pickFirst in  packagingOptions to avoid duplicate file copying to APK as below.



Leave a Reply

Your email address will not be published. Required fields are marked *