I'm using Studio 3.3.1 Build from Jan 28.
For me I was getting the "error android resource linking failed" pointing to a line in a layout file using ConstraintLayout that had been working correctly until today when the only change to my app level gradle file was to update the versions of:
android.arch.navigation:navigation-fragment
android.arch.navigation:navigation-ui
from 1.0.0-rc01
to 1.0.0-rc02
.
The error message said something about not recognizing layout_constraintTop_toTopOf
which of course is silly because it had been compiling quite happily for months.
I am already on 28.0.3 of build tools and compileSdkVersion
of 28. I've been using androidx.appcompat
everywhere for a while now (converted this project months back to androidx).
I first went through a project clean (no help), and invalidating cache/restart (no help). The layout in question had been originally defined using
<TextView>
, <EditText>
and <ImageView>
components (which had been working fine until today).
But after reading the above answers I thought maybe somehow there was confusion being caused here so I changed the layout to use:
<androidx.appcompat.widget
versions of all the various components. No change - still got the error.
I then deleted the <androidx.appcompat.widget.AppCompatTextView
block that was causing the compilation error. I changed all references to it in the other widgets to refer to "parent" instead. Did a Make. This time the compile completed without error.
So something strange in that widget definition I thought....here is what it was:
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/contact_firstname_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/contact_fname_label"
android:gravity="end"
android:textAppearance="@android:style/TextAppearance.Material.Small"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/contact_detail_fname"
app:layout_constraintBaseline_toBaselineOf="@+id/contact_detail_fname"/>
I then pasted back the block I had Ctrl-V cut previously and changed the references back to that ID in the other components that reference it in the layout. Compile failed.
I cut the block again and pasted it to WordPad. Then reading from the WordPad paste, I actually typed it back in (i.e. I didn't copy/paste this time) - line by line, doing a make on the project after I typed in the minimal definition, and then again thereafter when I put in each new line. Each time the project compiled cleanly!
I don't know what to make of this. Perhaps some spurious invisible character was in the file originally?