Phileo99
Phileo99

Reputation: 5659

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?

Upvotes: 8

Views: 13679

Answers (5)

Yossi
Yossi

Reputation: 6027

I had the same issue on Windows 10, running from the command line and did the following:

  • Deleted the specified path, which was empty
  • rebuilt using react-native run-android

Upvotes: 0

Namrata Bagerwal
Namrata Bagerwal

Reputation: 1210

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)

Upvotes: 7

Digvijaysinh Gohil
Digvijaysinh Gohil

Reputation: 1455

I have the same issue and also disable Instant Run, I navigate to that path and find out that the folder is empty.

Then I simply rebuild the project and the issue is gone.

(Android Studio v3.0.1)

Upvotes: 0

Omid Heshmatinia
Omid Heshmatinia

Reputation: 5236

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.

Upvotes: 1

Yash Jain
Yash Jain

Reputation: 374

Yeah, I encountered the same problem.

Workouts-> Once the app is installed, it shows indexing and says failed to open app. This is what happened with me. If your case is the same then just install the app and open the app from the emulator by clicking it. the thing is that the app is installed but it isn't opening. So just open it manually

Upvotes: 0

Related Questions