27

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.

Hesam
  • 52,260
  • 74
  • 224
  • 365
  • I encountered the same problem. I think it might have something to do with having different manifest files with different package names. (e.g. com.something.free and com.something.paid). – metaphyze Mar 19 '15 at 14:29
  • @metaphyze thanks man. Funny thing is I checked out to its parent branch and tried to build it to see what happens. Same thing happened :( so confused... So should be more serious... – Hesam Mar 20 '15 at 02:25
  • 1
    I think I see the problem. Do you have your crashlytics files committed to source control? Assuming you're using git, you need to untrack them (not delete them from the file system). I had mine committed. Here's what I did. 1) add com_crashlytics_export_strings.xml crashlytics-build.properties to the .gitignore file 2) git rm --cached all those files. This will remove them source control tracking but leave them on the file system. 3) Clean the build. There's a comment in those files that says "#Do NOT modify, delete, or commit to source control!" – metaphyze Mar 20 '15 at 02:39
  • Couldn't figure out what was the problem but pulled project again into new directory and in this directory was working fine. I will write the answer if I could figure out what was that problem. btw, new pull of repo fixed this mysterious problem! – Hesam Mar 20 '15 at 03:48
  • @metaphyze, Thanks man for your time, I checked repo and those files are not under version control. – Hesam Mar 20 '15 at 03:51
  • 1
    I had the same problem, one of my dependencies had mistakenly added the com.crashlytics.android.build_id via craslytics's auto genereted xml file. Deleting it fixed it for me – bugraoral Mar 20 '15 at 09:16
  • This problem just came out of nowhere for me. As we are all suddenly seeing this, perhaps we've all updated Android Studio, or Android Tools, recently? – Justin Mar 20 '15 at 20:26
  • @Justin yes I have recently updated my gradle stuff, that might be the trigger but for my case I had always had that problem but did not recognised it since. – bugraoral Mar 22 '15 at 21:45

5 Answers5

38

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'
Alex Burov
  • 1,881
  • 1
  • 17
  • 13
19

I had the same problem.

My mistake is I add fabric plugin and firebaseCrashlytics plugin on my gradle. (reason : plugin build id duplicate crash)

You must fix select A and B plugin.

A : apply plugin: 'com.google.firebase.crashlytics

B : apply plugin: 'io.fabric

Park
  • 401
  • 4
  • 10
  • should we add both or old fabric needs to be removed? – Giteeka Sawlani May 07 '20 at 16:49
  • 2
    @GiteekaSawlani You should remove either. But i recommend removing the fabric. Because firebase's crashlytics was officially released [ https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android ] – Park May 08 '20 at 08:12
14

I had the same problem, one of my dependencies had mistakenly added the com.crashlytics.android.build_id via craslytics's auto genereted xml file.

It was a library project and deleting :

library/src/main/assets/crashlytics-build.properties
library/src/main/res/values/com_crashlytics_export_strings.xml

fixed it for me.

bugraoral
  • 2,630
  • 1
  • 21
  • 25
  • 1
    It happened to me again after I installed Fabric plugin. I uninstalled the plugin but problem was there. Then deleted mentioned files from my dependencies and problem fixed. Thanks @wrecker – Hesam May 05 '15 at 04:51
  • I got this issue after updating an old code base from Crashlytics to Fabric and tried this suggestion (at least just deleting the .xml file in my case), which worked. I also confirmed it was the correct solution with the Fabric support team. – CMash Nov 03 '15 at 09:10
8

Fix different io.fabric.tools:gradle versions

Different io.fabric.tools:gradle versions in the app and library caused this for me.

I'd the following in the app's build.gradle:

classpath 'io.fabric.tools:gradle:1.19.2'

And the following in the library's build.gradle:

classpath 'io.fabric.tools:gradle:1+'

I changed both to following to fix it:

classpath 'io.fabric.tools:gradle:1.19.2'

PS: We need better error messages. As programmers we waste of lot of time when the error messages are not only bad, but as in this case, downright misleading.

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
0

remove this also besides fabric

crashlytics {
   enableNdk true
 }
Ambesh Tiwari
  • 648
  • 7
  • 11