9

I have a problem with the latest beta update trying to refactor the view or xml layout name id in xml. The error dialog says

Refactoring cannot be performed File C:\dev\workspace......\R.java is read-only.

Things I've tried:
Gradle clean, Invalidate cache/restart. None helped. I also tested with strings and other resources. The same problem happens there.

The problem appeared in the beta 4 update. In beta 2 refactoring worked fine.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Ooba Elda
  • 1,622
  • 1
  • 12
  • 18
  • yes it is a reported bug. revert back to previous version. – Atef Hares Sep 02 '17 at 12:03
  • @AtefHares [beta 3](https://developer.android.com/studio/archive.html) doesn't exist. They removed [because of issues with Gradle](https://androidstudio.googleblog.com/2017/08/android-studio-30-beta-3-is-now.html) . If you see the first link with a list of the releases, beta 3 isn't listed. And beta 3 is **extremely bugged**, avoid it if you somehow can get your hands on it. Revert to Beta 2 instead if you decide to revert – Zoe Sep 02 '17 at 12:05
  • @LunarWatcher Yes you are correct. Sorry, I just forgot about this! – Atef Hares Sep 02 '17 at 12:07
  • @LunarWatcher, i am on beta 4, not 3. I updated through the android studio itself – Ooba Elda Sep 02 '17 at 12:09
  • 1
    AtefHares suggested you revert back to beta 3 from beta 4. I know beta 4 is released, but reverting back to beta 3 is a horrible idea. I explained **why** reverting back to beta3 shouldn't be the solution. If you are going to revert, revert to beta 2, not 3. I know you run 4. If you want to solve it instead of reverting, I urge you to look at [this](https://stackoverflow.com/q/45879726/6296561) - I'm not marking as a dupe because that post is about beta 3. With beta 3 being extremely bugged, the beta 4 could have a different cause. – Zoe Sep 02 '17 at 12:10
  • @LunarWatcher is it possible to download the beta 2 version now? The preview site has only latest build available for download. edit: found it here https://developer.android.com/studio/archive.html – Ooba Elda Sep 02 '17 at 12:19
  • Well I can't refactor my strings in the xml file... canary 6 fix this problem? – JavierSegoviaCordoba Sep 05 '17 at 16:21
  • getting same problem on beta 4 – AskQ Sep 06 '17 at 11:02
  • Another user found a workaround here: https://stackoverflow.com/a/46064561/8575353 – drulex Sep 08 '17 at 01:22
  • @ajora cleaning is not solution because you loose generated R.java, and as the result, can not access resources from code. Only solution there still reverting back to Beta 2. – konata Sep 08 '17 at 21:21

2 Answers2

4

Android Studio Beta 5 has solved this problem.

JavierSegoviaCordoba
  • 6,531
  • 9
  • 37
  • 51
  • Indeed. Do you know if there's any way to make the "set current layout as default" actually work? I'm on a mac and I can't get it to work properly. It seems like it's setting the proper settings in the window.manager file in the preferences folder, but when I click restore default layout (or just navigate away from and back to a layout file) my component tree window and palette windows both start floating and get really small. – LukeWaggoner Sep 13 '17 at 00:13
0

I am experiencing the same issue on Android Studio 3.0 Beta 5 and 6. If your R.java file is read-only and your package name is com.example.sample just remove the file app/build/generated/source/r/debug/com/example/sample/R.java (R.java,Manifest.java...), then try again when you're finished refactoring, it will be regenerated during the build process.

Dexter
  • 754
  • 6
  • 14