Resource entry com.crashlytics.android.build_id is already defined

Hesam picture Hesam · Mar 19, 2015 · Viewed 10.1k times · Source

My project was working and everything was fine but have no idea what happened suddenly that I'm getting error when I want to build my project. This is Gradle output:

/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/values.xml:265: error: Resource entry com.crashlytics.android.build_id is already defined.
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/com_crashlytics_build_id.xml:9: Originally defined here.

Since both of these files are auto generated I cannot do anything :(

  1. I tried to clean project by Build>"Clean project" but nothing happened.
  2. I tried to clean project by ./gradlew clean assembleDebug but nothing happened.
  3. I tried to invalidate cache of Android Studio by File>"Invalidate caches / Restart" but nothing happened.
  4. I even restarted my f.laptop but still same problem displays when I build the project.

I have this classpath in my build script but as mentioned it was working...

dependencies {
        classpath 'com.android.tools.build:gradle:1.0.1'
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }

Any suggestion would be appreciated. Thanks.

Answer

Alex Burov picture Alex Burov · Mar 17, 2020

I have an app of two flavors: Debug and Release, with two manifests and two distinct packages com.myapp.release and com.myapp.debug for each flavor, respectively.

After migration from Fabric.io to Firebase Crashalytics, a Gradle warning appeared about duplicate com_crashlytics_build_id.xml:

/home/.../app/build/generated/fabric/res/flavor1/debug/values/com_crashlytics_build_id.xml  [string/com.crashlytics.android.build_id] /home/.../app/build/generated/crashlytics/res/flavor2/debug/values/com_crashlytics_build_id.xml: Error: Duplicate resources

Fix: in build.gradle

remove

dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
  }

remove

apply plugin: 'io.fabric'