ConstraintLayout unnecessary error


ConstraintLayout unnecessary error



I'm using ConstraintLayout wrapped with layout tags for dataBinding, all layouts works fine in execution and runtime, but I got an annoying issue:


ConstraintLayout


layout


dataBinding



xml screenshot



As you see, constraint id's say "Cannot resolve symbol '@+id/tvAccount'", seemed as errors when trying to commit, but there's nothing wrong with workflow or the app, and all works fine as intended. It's same in all xml files. Cleaning, invalidating cache etc. is not fixing it. Has anyone met the same issue ?



Edit:
XML code for splash, it'll say "Cannot resolve symbol '@+id/imageViewSplash'" when you hover on the app:layout_constraintTop_toBottomOf="@+id/imageViewSplash" :


app:layout_constraintTop_toBottomOf="@+id/imageViewSplash"


<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<!--suppress AndroidUnknownAttribute -->
<data class="SplashBinding"/>

<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.splash.SplashFragment">

<ImageView
android:id="@+id/imageViewSplash"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_marginBottom="8dp"
android:contentDescription="@string/content_description_splash_icon"
android:src="@mipmap/splash_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/imageViewSplashLoader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/content_description_splash_loading"
android:src="@mipmap/splash_loader"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageViewSplash"/>
</android.support.constraint.ConstraintLayout>
</layout>



Edit 2:
It's same error when you hover on app:layout_constraintTop_toBottomOf="@+id/imageViewSplash", even without <layout> tags:


app:layout_constraintTop_toBottomOf="@+id/imageViewSplash"


<layout>


<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.splash.SplashFragment">

<ImageView
android:id="@+id/imageViewSplash"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_marginBottom="8dp"
android:contentDescription="@string/content_description_splash_icon"
android:src="@mipmap/splash_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<ImageView
android:id="@+id/imageViewSplashLoader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/content_description_splash_loading"
android:src="@mipmap/splash_loader"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageViewSplash"/>
</android.support.constraint.ConstraintLayout>





share your xml layout as text not as image thanks
– Nilesh Rathod
Jul 3 at 9:24





@NileshRathod sharing as text does not highlight errors on here
– Melih Aksoy
Jul 3 at 9:27





@TimCastelijns it still persists after removing +
– Melih Aksoy
Jul 3 at 9:28





@MelihAksoy can u share your layout code
– Nilesh Rathod
Jul 3 at 9:29





@MelihAksoy delete the constraint and again set it from Design tab.
– Nainal
Jul 3 at 9:30




1 Answer
1



After keeping layout in the editor i might have got the solution for you. The possible cause here is might be with the xmlns:bind and xmlns:android


xmlns:bind


xmlns:android



Please try following it's not showing me any error.


<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res/android">

<data></data>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/tvAccount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="13dp"
android:layout_marginEnd="32dp"
android:text="Account"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tvPhoneValidationTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Phone Validation"
app:layout_constraintEnd_toEndOf="@id/tvAccount"
app:layout_constraintStart_toStartOf="@id/tvAccount"
app:layout_constraintTop_toBottomOf="@id/tvAccount" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>





No luck, it's same thing on layouts without binding ( I added another snippet ). Seems it's happening on "app:constraint" under all circumstances atm..
– Melih Aksoy
Jul 3 at 9:50





It's only showing error in the layout? Not troubling in the execution?
– Brijesh Joshi
Jul 3 at 9:52





No, not at all. Everything is as expected and working for all the layouts in execution and runtime. It's an error in the XML editor only.
– Melih Aksoy
Jul 3 at 9:55





That's the strange behavior of studio.. Ha ha
– Brijesh Joshi
Jul 3 at 9:57





Indeed.. And it doesn't look good when you want to commit, it keeps prompting there are 20 errors, all of them are these references lol
– Melih Aksoy
Jul 3 at 9:58






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?