1

I am running Ubuntu 16.04 with Android Studio 2.3.2 and Gradle 3.3. i just downloaded android studio and made a project. The target of the project is Android KitKat. When I try to run it, it gives and error saying "Execution failed for task ':app:compileDebugJavaWithJavac'..."

I just created this project and have not added any code.

Full Error Screenshot: Error Message

WhatsYourIdea
  • 351
  • 2
  • 12
  • 2
    Try `Build > Clean Project` and then build it again – zeekhuge Aug 22 '17 at 01:52
  • Are you using user **bill** to start the Android Studio? Try to use command **unzip** to extract the zip file to see whether it can be extracted. – cmoaciopm Aug 22 '17 at 02:04
  • Just tried Clean Project, but the same error still comes up! Also, unzip seems to have successfully unzipped the classes.jar file. – WhatsYourIdea Aug 22 '17 at 02:22
  • @WhatsYourIdea Can you build your project in command line? In your project root folder, execute "gradle assembleDebug" – cmoaciopm Aug 22 '17 at 02:30
  • @cmoaciopm Ubuntu asked me to install gradle with "sudo apt install gradle". And after the installation, I ran "gradle assembleDebug". And this time, another error showed up. Error: https://www.mediafire.com/file/9184u8a65l33uno/GradleVersionError.txt – WhatsYourIdea Aug 22 '17 at 03:18
  • @WhatsYourIdea Ubuntu release bundled gradle(2.10) is too old to compile the project. From the log, you should use gradle 3.3 to compile your project. I recommend you to use **sdkman** to install gradle. Refer http://sdkman.io/install.html. – cmoaciopm Aug 22 '17 at 03:22
  • @WhatsYourIdea Or else you can use execute "./gradlew assembleDebug" in your project root, if you don't want to install gradle by yourself. This method is much simpler. – cmoaciopm Aug 22 '17 at 03:28
  • @cmoaciopm gradlew didn't work either. It showed the same error as android studio gave me. – WhatsYourIdea Aug 22 '17 at 03:38
  • @WhatsYourIdea Can you take a screenshot of your command line console? Which user are you using to execute the gradle command line? – cmoaciopm Aug 22 '17 at 03:40
  • @cmoaciopm I am not using root but a normal account to execute gradle. Screenshot: https://www.mediafire.com/file/9jlsgb19d98rcim/ErrorMessage.png – WhatsYourIdea Aug 22 '17 at 03:45
  • @WhatsYourIdea Weird. Try "rm -rf /home/bill/.android/build-cache" to remove the build cache, then rebuild. – cmoaciopm Aug 22 '17 at 04:37
  • @cmoaciopm Thank you! I finally found the solution. – WhatsYourIdea Aug 23 '17 at 08:36

1 Answers1

2

After a long search, I finally found the cause and the solution.

Cause:

The problem was caused by an automatically mounted ntfs hard disk. I saved all my projects files in an ntfs partition, but Ubuntu recognized the ntfs partition as a removable device (e.g. USB).

Solution:

1. Run sudo umount <name of the drive (e.g. /dev/sda1)> to unmount the drive in problem.
2. Run sudo cp /etc/fstab /etc/fstab.backup to make a backup of fstab.
3. Open /etc/fstab with any text editor.

Here, find the line that specifies your ntfs partition. The line should look like this:

UUID=<16 digit uuid>    <something>     ntfs    defaults,umask=007,gid=46              0      0

Add errors=remount-ro,uid=1000 after defaults,umask=007,gid=46
So after the change, it will look like this:

UUID=<16 digit uuid>    <something>     ntfs    defaults,umask=007,gid=46,errors=remount-ro,uid=1000    0      0
  1. Reboot your system

Now, gradle should not give the execution failed error anymore.

WhatsYourIdea
  • 351
  • 2
  • 12