Error: Finish can only be called once - android

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?

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..

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.

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.
on windows : C:\Users\YourUserName) enter .gradle directory and erase caches directory

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

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

A simple restart of android studio works.

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.

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;

recreate andoid studio configuration.
close problem project.
remove .iml files and .gradle .idea directories.
open project.

Related

Gradle sync failed: Could not create parent directory for lock file

I checked out a git repository in android studio, but I'm in trouble with Gradle sync failed error.
When project wants to build, the android studio raise an error like as following:
Gradle sync failed: Could not create parent directory for lock file
C:\Users\username\.gradle\wrapper\dists \gradle-4.10.1-
all\455itskqi2qtf0v2sja68alqd\gradle-4.10.1-all.zip.lck
I saw some answers to the other almost same problems, but none of
them help.
Also I deleted cashes in .gradle directory according above path, but it does not work.
How can I solve this problem?
I appreciate you to solve this problem, thanks.
I found this answer:
In the upper-right corner of android studio click on the Gradle tool,
then right click on the your project name then click on the Refresh Gradle project as following:
Then click on the Build -> Rebuild Project as following:
Run this following command:
gradlew clean
gradlew assembleDebug
If this does not work use following command.
gradlew --update-locks assembleDebug
Remove C:\Users\yourname.gradle
then close android studio
and Start Android Studio with administrative permission.
it fixed in my case.
For anyone who still encountering this issue, I have just ran the Android Studio as administrator and it worked.

Please configure Android SDK

I am getting this error:
Please configure Android SDK
Onclick of configure i getting one popup
After changing Build Tool Version on the pop screen
26.0.1 changed into 26.0.3 // else selected the highest available version
then click OK started working for me...
(or)
Simply Restart Andoid Studio File->Invalidate Caches and restart
FIX FOR 3.1.2 OR NEWER VERSIONS
I faced the same issue on Android studio 3.1.2, but a simple Sync didn't work for me.The solution was a bit different:
I go to
File -> Invalidate Caches -> Invalidate
File -> Close Project.
Remove the project from the Android Studio project selector window.
Quit from Android Studio(X)
Start Android studio and open project again
I consumed a few hours to fix this issue:
First Click 'Sync' gradle
Then clean and rebuild the application
And invalidate and restart
You can close this project first.
Then DELETE ALL temp file and generated file,
including .gradle, .idea, build in your project's root directory and also build in app path.
Finally, restart your project, problem should be solved. Good Luck !
After executing these two adb commands, it also works fine for me.
(1) adb kill-server
(2) adb start-server
I had the same issue and tried all of the above and it did not help.
I ended up closing everything and rebooting my Mac.
Reopened Android Studio and it was back to normal :)
In build.gradle (Module: app) I changed "compileSdkVersion 23" to 26
Then it works.
Maybe also work for you.
For me solution was to sync project with gradle files.

Re download dependencies and sync Project in Android studio

After updating Android Studio 2.3.3 all this happing.
I am creating a new Android Project after indexing and Gradle synchronization it shows an error Re-download dependencies and sync project(required network)
when I click on click on Re-download dependencies and sync project nothing would happen it again shows error.
I have also tried invalidate cache and Restart and also sync the Gradle but nothing happens
I have also good connectivity of the internet.
It seems to be a gradle dependency cache problem. Unfortunately File | Invalidate Caches/Restart only cleans system cache as described here
To clean the gradle cache you need to run command
for Windows gradlew cleanBuildCache
for *nix ./gradlew cleanBuildCache
It will only clean cache related to your project. More details here
Another option is to delete gralde cache directory contents manually:
Windows: %USER_HOME%.gradle/caches
*nix: $HOME/.gradle/caches/
You can try this:
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
Replace the url in your project with this URL and then rebuild your project.
Hope that works
You can just delete the gradle 2.3.3 in the ./gradle/dists/wrapper directory and close the project and open it again .. This will allow it to download it again
try to invalidate the cache and restart in android studio.
for Windows gradlew cleanBuildCache.
for Linux ./gradlew cleanBuildCache.
or try to delete cache using some cleaner like C cleaner.
If you're on linux like me, starting studio with sudo from terminal does it.
sudo ./{path to studio}/bin/studio.sh
I have the same problem when I updated my Java SDK
I solve the issue by doing the following
...
Close your android studio
Delete the .gradle folder from home folder
Start Android Studio and it will forced to download the new .gradle

Gradle sync failed: Failed to create parent directory

I've faced a problem during the installation process of the android studio. I've ignored the failure at the start and after creating a project,it stated that "Gradle sync failed: Failed to create parent directory".
I've downloaded most SDK and searched for possible answers online but I'm still not able to solve the problems.
Please provide me with all the help possible. Thank you
In my case, I have pulled my repository, and it was displaying this error. To fix, just run the commands:
flutter clean
and then:
flutter run
It is because android studio needs admin privilege to create directory in that path.
So, to solve this problem simply run android studio as administrator
Look at the location its failing to create, go to that location and delete cache folder, worked for me
deleting the build folder in the android/app directory fix my problem
I run chown -R user:user /path/to/.gradle.
I found some of the directories had been owned by root. Maybe its because, during software update, i was forced to run Android Studio or IntelliJ IDEA as root due to installing them under /usr/local
If you are building project on same computer just run flutter clean and then invalidate caches and restart project.
else delete build folder from project directory.
delete the build folder in the android/app

Execution failed for task ':app:packageDebug' - Failed to read zip file

Without any changes in my code, suddenly i get this error when I try to run my app:
What went wrong:
Execution failed for task ':app:packageDebug'.
com.android.builder.packaging.PackagerException: java.io.IOException: Failed to read zip file 'C:\Users\Eliran\AndroidStudioProjects\Forum\app\build\outputs\apk\app-debug.apk'.
I have no idea why its trying to read the apk as zip file.
If I restart Android Studio, I can run the app once and then It happens again.
For me it helps (for now) when I Exit Android Studio, next I used Windows Task Manager (Ctrl + Shift + Esc) and kill process Java(TM) Platform SE binary and delete that file manually. After that I run Android Studio again, click on the Clean Project (there can be an error with app:clean, but you can run Android Studio again) and next click Make Project - after that of course Run 'app' button in Android Studio.
This issue has been reported to the development team: https://code.google.com/p/android/issues/detail?id=210693&thanks=210693&ts=1463824240
Its solve my problem perfectly. i Just delete my build file and file>> Invalidate and restart android studio. This problem occur for me change dependency version
I try manual delete file, but the SO inform: the file "app-debug.apk" is in use by "OpenJDK Platform Binary". Then I kill "OpenJDK Platform Binary" and this worked.
If you are using flutter, type
flutter clean
and restart your ide. It worked for me.
After wasting my 4 hours i could fix this.
I fixed it by deleting ~/.android/debug.keystore file.
1.delete debug.keystore file
C:\Users\xxx\.android\debug.keystore
flutter clean
restart ide
just delete debug.keystore file under .android

Categories

Resources