2

Adding the Firebase dependency seems to break the Gradle build of the default Android Studio project. Here's what I did:

  1. I created a new default Android app in Android Studio. It built fine out of the box.
  2. I added the Firebase Gradle dependency to the app/build.gradle file:

    ...
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.firebase:firebase-client:1.0.16+'
    }
    
  3. Gradle sync broke with this error:

    Error:duplicate files during packaging of APK /Users/mimming/code/firebase-rawr/app/build/outputs/apk/app-debug-unaligned.apk
        Path in archive: META-INF/LICENSE
        Origin 1: /Users/me/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.2.2/stuff/jackson-annotations-2.2.2.jar
        Origin 2: /Users/me/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/stuff/jackson-databind-2.2.2.jar
    
mimming
  • 13,974
  • 3
  • 45
  • 74

1 Answers1

5

This is caused by a bug in how Gradle treats dependencies. It's being tracked in the Android OSP bug tracker.

You can work around this bug for Firebase by adding a couple of excludes to your app/build.gradle file:

android {
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
...
}
mimming
  • 13,974
  • 3
  • 45
  • 74