Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't rename resource (layout) files (Android Studio 3.0 Beta 3 is installed)

Beta 3 doesn't allow to rename resource files such as layout files. It does show the renaming dialog, but when trying to apply changes it reads the following error message:

Refactoring cannot be performed
File .../myapplication/R.java is read-only

Also I have Beta 2 version in a neighbor directory and renaming works perfect. Any ideas how to fix that?

UPD: I reported the bug (#65079508), and now it is marked as a duplicate of 65032914 https://issuetracker.google.com/issues/65032914

So, the issue is even wider and if I understand it well the bug will be fixed in some coming version of the Studio.

UPD#2: Beta 4 is released. The bug is still not fixed.

UPD#3 Fixed in Beta 5.

like image 454
Roman Avatar asked Aug 25 '17 10:08

Roman


People also ask

Can you rename activity in Android Studio?

Click on the activity file from the project structure. Press "Shift + F6 ", you will be asked to rename the activity. Enter the new name and press Enter.

Can the Android layout folder contain subfolders?

You can organize your resources XML files (layout, drawable,..) into separate subfolders corresponding to the app's features.


3 Answers

meh, just get rid of the generated files && then refactor.

Gradle --> app --> build --> clean.

Gradle clean project (remove generated files/folders)

like image 92
wooldridgetm Avatar answered Oct 23 '22 06:10

wooldridgetm


I am experiencing the same issue on Android Studio 3.0 Beta 3. I fixed the problem by:

  1. Exiting Android Studio
  2. Navigating to the folder that the layout file is saved in (either CLI or GUI)
  3. Rename the file to whatever you want the refactored file to be called.
  4. Reopen Android Studio.

Obviously this forces you to have to manually refactor the references to the old file, but I tried about a dozen different things (changing R.java permissions, Gradle clean, invalidate cache, etc.) and none of them worked.

Anyone else who has this issue should submit this bug in Android Studio by using Help > Submit Feedback.

Also, is there a chance you might also be using multiple layouts folders like I am?

like image 37
spitfyre Avatar answered Oct 23 '22 05:10

spitfyre


I've got the same issue. I was solved this with

File --> Invalidate Caches and Restart --> Invalidate and Restart.

And than try to rename again.

Hope this help. Happy coding :)

like image 2
Bayu Wijaya Permana Putra Avatar answered Oct 23 '22 07:10

Bayu Wijaya Permana Putra