26

I have a problem with Gradle building. When I build my project, it displays the error:

Finish can only be called once in android studio

Anyone have idea about this error?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Phạm Lam
  • 378
  • 1
  • 3
  • 14
  • 1
    try invalidate cache and restart android studio, and after that clean your project and rebuild it – Shrenik Shah Mar 06 '17 at 11:06
  • 1
    Thanks for your suggestion but what do you mean invalidate cache? I did these all steps yet but it's still not running. – Phạm Lam Mar 06 '17 at 11:25
  • 1
    To Invalidate cache and restart. See my answer [here](http://stackoverflow.com/questions/43842737/errortrouble-processing-java-lang-autocloseable-class/43843010#43843010) – Shashank May 08 '17 at 08:45

9 Answers9

35

in android studios go to ....
file > invalidate caches and restart ....
click invalidate and restart button in confirmation dialog..
might take few time to build Gradle..

harsh patel
  • 511
  • 5
  • 9
  • This seems like the cleanest solution and IMO should be marked as the accepted answer. It worked for me and has the bonus of not going into the file system and wiping out system folders ;) – head in the codes Sep 05 '17 at 19:46
14

I was able to resolve this issue by stopping the currently running gradle daemon so from command line:

./gradlew --stop

Or if you're using android studio: Restart android studio.

I've cleared the cache in advance but it didn't work.

coffeemakr
  • 330
  • 2
  • 12
11

Close Android Sudio, on your Home directory (on windows : C:\Users\YourUserName) enter .gradle directory and erase caches directory, then restart Android Studio and the error should be solved.

enter image description here

on windows : C:\Users\YourUserName) enter .gradle directory and erase caches directory

Community
  • 1
  • 1
from56
  • 3,976
  • 2
  • 13
  • 23
1

if you run Android Studio as root, then run gradle commands as root too, try sudo ./gradlew assembleDebug or sudo ./gradlew assembleRelease

askoura
  • 61
  • 2
  • 3
1

There are many sophisticated answers. But for me none of this helped, only reboot.

Roman Minenok
  • 9,328
  • 4
  • 26
  • 26
1

A simple restart of android studio works.

Harsh Phoujdar
  • 670
  • 10
  • 22
0

People, if you are using Android Studio in mac, by default you will be getting a BUILD file added in your project.Not sure whether it is bug or might be added default to all Android Studio Projects. Make sure to delete BUILD file and then restart Android Studio. If you see the same error "Error: Finish can only be called once" again then restart your computer.As i faced this issue many times, this solutions worked for me.

Ravi
  • 631
  • 5
  • 15
0

error "Finish: only can be called once"

Gradle cache problem: The default amount of cache path in:

on windows: C: \ Users \ YourUserName)

1, exit the studio

2, enter the cache path, find C: \ Users \ Administrator . Gradle

3, delete the caches folder or delete. gradle folder

4, restart studio to rebuild;

Fakhriddin Abdullaev
  • 4,169
  • 2
  • 35
  • 37
-3

recreate andoid studio configuration.

  1. close problem project.
  2. remove .iml files and .gradle .idea directories.
  3. open project.
okay
  • 1