Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error, failed to create directory

today jump into such problem when launching test class using roboelectric and junit:

Information:Gradle: Executing tasks: [:app:assembleDebug, :app:assembleDebugUnitTest]
Error:Gradle: failed to create directory 'E:\AndroidKotlin\FooApp\app\build\generated\source\r\debug\com\example\foo\fooapp'
Error:Gradle: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
Error:Gradle: com.android.builder.internal.aapt.AaptException: AAPT2 link failed:
Error:Gradle: Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt

Maybe someone has meet such nasty thing earlier and would be so nice to help me ;) ? If u don't have any idea, please let me know how can I try finding it on my own. I already did clean project and rebuild :)

like image 426
kolboc Avatar asked Oct 01 '17 13:10

kolboc


2 Answers

I solved it by changing the JDK version I was using:

  1. Go to File -> Project Structure.
  2. On the left side, click on SDK Location and go to JDK Location.
  3. Change it to the Embedded JDK that comes with Android Studio.
  4. Click on OK.
like image 159
Abdelrahman Tareq Avatar answered Sep 18 '22 15:09

Abdelrahman Tareq


Finally managed to get rid of all unwanted stuff with AS option:

File -> Invalidate caches / Restart
like image 20
kolboc Avatar answered Sep 18 '22 15:09

kolboc