How do I resolve “Duplicate files copied in APK META-INF/*”

后端 未结 6 1594
粉色の甜心
粉色の甜心 2020-11-30 01:48

I am working at a commercial android application. I am also using some libraries licensed under different license types some of them stating the following:

If th

相关标签:
6条回答
  • 2020-11-30 02:01

    Surely it will work

    packagingOptions {
     exclude 'META-INF/LICENSE.txt'
     exclude 'META-INF/NOTICE.txt'   }
    
    0 讨论(0)
  • 2020-11-30 02:03

    Add following into respective build.gradle file

    packagingOptions {
            exclude 'META-INF/ASL2.0'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/MANIFEST.MF'
        }
    
    0 讨论(0)
  • 2020-11-30 02:05

    I think you need to include only these options in build.gradle:

    android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
        }
    }
    
    0 讨论(0)
  • 2020-11-30 02:16

    There is a solution if you have only one license using the name license.txt (read: all license.txt copies are identical):

    packagingOptions {
       pickFirst  'META-INF/license.txt'
    }

    Otherwise, Google also released a Gradle plugin to manage dependencies licenses. See here. I didn't try it, but it looks like it's capable of aggregating every dependency, and even generating an activity displaying all of those licenses.

    0 讨论(0)
  • 2020-11-30 02:16

    You can add multiple licence in gradle see this

    0 讨论(0)
  • 2020-11-30 02:19

    I faced the same issue with my application. You need to make sure you have not added any libraries twice. If you have followed the firebase documentation https://firebase.google.com/docs/android/setup

    Then you should not add firebase library inside android studio i.e. file->project structure->cloud->firebase

    You have to do only one of the both, to use firebase in your android application.

    At the end clean and rerun your app.

    0 讨论(0)
提交回复
热议问题