Vlad Iancu
Vlad Iancu

Reputation: 487

Updated Android SDK and Android Studio messed up all my XMLs: "Element XXX not allowed here"

I just updated my Android Studio and Android SDK, and now I can't do anything in my XMLs. It shows the same thing as previous, but I can't add anything and something got messed up.

Example:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <ImageView
        android:id="@+id/bocterAppLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/bocterapp"
        android:contentDescription=""/>
</LinearLayout>

It error says: "Element ImageView is not allowed here".

Do you have any idea why this has happened?

Cheers!

Upvotes: 6

Views: 4589

Answers (2)

Boycott A.I.
Boycott A.I.

Reputation: 18871

I also had the same problem. In my case, I was using a container from the old support library. So changing

<android.support.constraint.ConstraintLayout ... />

to

<androidx.constraintlayout.widget.ConstraintLayout ... />

solved it for me - with no change to the ImageView.

Upvotes: 0

prograde
prograde

Reputation: 2740

I had the same problem. Try to exchange the ImageView with the android.support.v7.widget.AppCompatImageView! That solved it for me.

Upvotes: 4

Related Questions