Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error related to resources_ap after upgrading to Android Studio 3.4

I upgraded Android Studio 3.4 today. I am no longer able to run the the app. I have cleaned the project, restarted Android studio many times. I have also invalidated cache to no avail. I am getting the following error when installing the app:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexWithInstantRunSlicesApkForDebug'.
> java.lang.RuntimeException: java.io.FileNotFoundException: E:\...\app\build\intermediates\instant_run_split_apk_resources\debug\instantRunSplitApkResourcesDebug\out\slice_1\resources_ap

Could anyone offer a tip on how to remedy this?

Edit: I have two projects with different behaviors related to this issue:

  1. Project A initially had this issue. I disabled Instant Run per the answer, the problem was solved. I enabled Instant Run later, and Project A is still working fine.
  2. Project B also had this problem that has been remedied by turning of Instant Run. However, its problem will occur as soon as Instant Run is turned on. I do not what difference between these two projects results in this. One suspect is library C project. Library C is a part of Project A (i.e. its source code, resources are in Project A). However, Project B uses the aar of Library C as a module.
like image 734
Hong Avatar asked Apr 22 '19 23:04

Hong


4 Answers

Issue should be fixed in Android Studio 3.4.2.


EDIT: Here is my old answer on how to fix it in Android Studio 3.4.0 and 3.4.1:

Using Gradle 5.4 instead of 5.1.1 helped me with this error.

Update gradle-wrapper.properties file with: distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip

Please note I haven't tested older Gradle versions, so it's possible even (for example) 5.2 version will work. You can see all Gradle releases here - https://gradle.org/releases/

like image 61
Robyer Avatar answered Nov 20 '22 18:11

Robyer


Switching off Instant Run as a workaround (File/Settings/Instant Run) seems to eliminate the problem.

According to OP it is possible to turn Instant Run back on without the problem recurring for some projects.

like image 30
Marco Borchert Avatar answered Nov 20 '22 16:11

Marco Borchert


There is no need to turn off Instant Run.
Just delete the '.gradle' directory in the project and build directory inside the 'app' module.
Perform Clean Project and Rebuild Project.
This will solve the issue.

like image 39
Bibin Johny Avatar answered Nov 20 '22 18:11

Bibin Johny


This is caused by "instant run" feature in android studio 3.4 , you can disable it by:

Open the Settings or Preferences dialog. Navigate to Build, Execution, Deployment > Instant Run. Uncheck the box next to Enable Instant Run

Enjoy...!

like image 6
Mahi Saini Avatar answered Nov 20 '22 17:11

Mahi Saini