Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Build Fails with "Could not read path" When Instant Run is Disabled

My Environment:

Android Studio 2.1.2
Android Gradle Plugin v2.1.2
Mac OSX v10.11.5

Up until now, I have turned off Instant Run when calling "Build=>clean Project" and running my project. The reason I have turned off Instant Run is because of this and this issue. However, recently, I started running into this problem every time I try to clean my project:

Error:Could not read path  
<path/to/app/module>/build/intermediates/classes/release/com/<package/name>/R$layout.class'.  

The interesting thing about this is that the specific file path that it can't find appears to be random. For example, if I call Gradle sync and then clean again, it will fail with this error:

Error:Could not read path  
<path/to/app/module>/build/intermediates/classes/release/com/<different/package/name>$ProductCategoryAdapter$1.class'.`

Steps to Reproduce:

  1. Preferences=> Build,Exec,Deploy => Instant Run
  2. uncheck "enable Instant Run...", "Restart activity....", "Show instant run...."
  3. Tap "Apply", then "OK", then do a Gradle Sync by tapping gradle sync icon in AStudio
  4. "Build=>clean Project"

Workaround

The current workaround is to re-enable Instant Run. However, that will also bring back the reason for turning it off.

Questions

1) Has anyone else encountered this problem?

2) Are there any other possible workarounds or even better yet, a solution to this problem?

like image 404
Phileo99 Avatar asked Jun 17 '16 17:06

Phileo99


2 Answers

To all the viewers visiting this page, as per my recent experience, 'Invalidate Cache & Restart' solves the problem. No need to disable/enable instant run and deleting folders manually. (Android Studio 3.0.1)

like image 128
Namrata Bagerwal Avatar answered Nov 17 '22 08:11

Namrata Bagerwal


I face the same problem. When i go to that address in explorer i see i can not open the folder and it gives permission error. So i close the Android studio and delete that specific folder from app/build directory and then restart the android studio.

like image 36
Omid Heshmatinia Avatar answered Nov 17 '22 07:11

Omid Heshmatinia