Reputation: 589
I recently deleted a fragment including its layout and viewmodel from my project. (FragmentAddFlight, VmAddFlight, fragment_add_flight.xml)
Surprisingly I am getting these errors:
[databinding] {"msg":"\u003cImageView id\u003d\u0027@+id/imageView2\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":277,"col0":20,"line1":286,"col1":85}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView4\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":308,"col0":28,"line1":312,"col1":64}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/editText8\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":314,"col0":28,"line1":318,"col1":60}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView5\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":327,"col0":28,"line1":331,"col1":63}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView14\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":333,"col0":28,"line1":338,"col1":57}]}
[databinding] {"msg":"\u003cImageView id\u003d\u0027@+id/imageView2\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":369,"col0":20,"line1":378,"col1":72}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView4\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":400,"col0":28,"line1":404,"col1":60}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/editText8\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":406,"col0":28,"line1":410,"col1":60}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView5\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":419,"col0":28,"line1":423,"col1":71}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView14\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":425,"col0":28,"line1":430,"col1":57}]}
[databinding] {"msg":"\u003cImageView id\u003d\u0027@+id/imageView2\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":452,"col0":20,"line1":461,"col1":77}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView4\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":483,"col0":28,"line1":487,"col1":60}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/editText8\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":489,"col0":28,"line1":493,"col1":60}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView5\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":502,"col0":28,"line1":506,"col1":71}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView14\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\Christoph\\Documents\\Android-Projekte\\FlightLogger\\app\\src\\main\\res\\layout\\fragment_add_flight.xml","pos":[{"line0":508,"col0":28,"line1":513,"col1":57}]}
Remember the file referenced in these error has already been deleted. Why do I get these errors?
I cleaned the project via Build -> clean project. I tried to rebuild the project via the same menu. But the result remains the same.
Does anybody have an idea how to solve this issue?
Upvotes: 25
Views: 15582
Reputation: 1
The right solution is here.
Step 1 : Remove this line from your build.gradle file
buildFeatures {
dataBinding = true
}
Step 2: Invalid cache & restart android studio Step 3: Close Android Studio Step 4: Let the android studio sync after doing step 2 Step 5: Restart your system
And woilaa..!!
Upvotes: 0
Reputation: 951
Any declaration of an id in an xml-layout should be unique.
This will be global in your app:
<LinearLayout
android:id="@+id/myLayoutId"
whilst this will not be global
<LinearLayout
android:id="@id/myLayoutId"
It won't be a problem usually, but something to keep in mind.
Upvotes: 0
Reputation: 569
Sometime this problem arise when you refactor(Rename) id in current file and it change that id in full project and this problem arises..
Upvotes: 0
Reputation: 938
Couldn't make it go without killing existing Gradle processes.
on Linux terminal:
pkill -f '.*GradleDaemon.*'
Upvotes: 0
Reputation: 1
If you are getting such issue then follow these instructions
if your system is Windows,
Now you get there is no such error. This process is worked for me.
Upvotes: 0
Reputation: 116322
If you use view-binding, you can add this to the layout till you have better IDs for the Views:
tools:viewBindingIgnore="true"
Do it for each problematic layout.
I found this tip from here.
Upvotes: 6
Reputation: 11
In my case there was the same ID assigned to different views in my XML file. I just changed one of them to avoid conflict then it worked.
Upvotes: 1
Reputation: 498
if File > Invalidate Caches / Restart > Invalidate and Restart
cannot solve your problem. Maybe you can try to
buildFeatures {
dataBinding = true
}
Windows
, open resource monitor
(because my computer is Chinese, so I don't know how to translate this word in the English system. Open cmd
, input perfmon
, and you will see it.)CPU
->Associated handle
->Search android
. buildFeatures {
dataBinding = true
}
Upvotes: 3
Reputation: 174
None of the above works for me: tools:viewBindingIgnore="true" , invalidate caches, gradlew assembleDebug
. All is not works.
The only way I found is delete the whole project and pull the source code again from git. Then build -> it run normally
Upvotes: -1
Reputation: 114
Sometimes none of the tricks explained above works as expected. Invalidate Cache and Restart Android Studio did not work for me at all. I tried the following command as well
gradlew assembleDebug
But it only works one time. I have to do this every time I make changes to the layout file. Try following these tricks if none of it is working for you
Upvotes: 1
Reputation: 81
It might be the case you accidentally make a layout-26 folder and inside that, there are two XML files of the same name.
Solution-:
1.Move the correct XML file from the layout-26 folder to the layout folder
2.Delete the layout-26 folder.
Upvotes: 0
Reputation: 29
Compile Time Issues: Fixed: 1.Clean the project. 2.clear cache and restart.
Make sure View binding is enabled.
Upvotes: 0
Reputation: 6499
Invalidate Caches/Restart
option sometime not working.
gradlew assembleDebug
Just try this command then see issue will no more available.
Upvotes: 4
Reputation: 145
To add on how to invalidate caches, in Android Studio, go to File > Invalidate Caches / Restart > Invalidate and Restart
Upvotes: 3
Reputation: 562
These files are created at compile time, so they might not have been deleted, Try invalidate caches and restart in android studio.
Upvotes: 51