Error: Unable to delete directory in Android Studio IDE

Error: Unable to delete directory in Android Studio - Too long I'm not publish a post :D hahaha maybe I'm realy busy. No just kid guys.

Some days ago, in my Android Studio IDE I getting an error every Clean Project, Build Project, or Clean and Rerun'app'. The errors shown like below

Error:FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:clean'.
> Unable to delete directory: /mnt/mydata/AndroidStudioProjects/DatePickerDialog/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.2.1/jars

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

In my opinion, this error happen when the directory package have different permission with Android Studio IDE. In this case, I using Linux with Ubuntu OS, and the place of directory package is on mount of second partition using NTFS partition.

The Some of the ways that I have tried, and I think this is a good ways. How it ways?

First, you need to open build.gradle in app package. And than copy and paste this small script on below of apply plugin: 'com.android.application'

task clean(type: Delete) {    
    delete "$rootProject/app/build/intermediates/exploded-aar"
}

Okay, the script will help Android Studio IDE to delete some files in the directory, now you can try to clean project.

Paper 4Share - Error: Unable to delete directory in Android Studio