Ethan Shoe
Ethan Shoe

Reputation: 574

How to Completely Remove an Android Layout from Android Studio

I'm building an app in Android Studio and I accidentally created a base LoginActivity template but then deleted it because I wanted to make my own. Now, when I try creating another activity with the same name, it tells me "Layout name must be unique."

I could just name it something else but:

  1. I don't want to
  2. There would still be some sort of duplicate files in my system doing nothing

My goal is to just remove all mentions of activity_login, ultimately so I can make a new activity with the same name, but I can't figure out how.

Upvotes: 2

Views: 1877

Answers (3)

yaner
yaner

Reputation: 77

I had the same problem. Empty res/layout/activity_xxxxx.xml and invalidate cache didn't work, until I found there's xxxxx.java existing in app\src\main\java\com\example\xxxxx. After deleting the .java file as well, I found that I'm able to create the Activity file with the same name.

Upvotes: 0

Kossei Necira
Kossei Necira

Reputation: 41

That's happens sometimes. just go to : File->Manage IDE Settings -> Restore Default Settings. This will solve it for sure :)

Upvotes: 0

touhid udoy
touhid udoy

Reputation: 4442

Go to res->layout->activity_login.xml and delete it from android studio

Or open project in file explorer, then Go to app/src/main/res/layout/activity_login.xml and delete it

If it didn't solve it, Invalidate Caches and restart Android Studio.

Upvotes: 7

Related Questions