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

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

Related

Build failed due to access denied in android studio

I cannot build my project on retrying it shows this error
https://i.stack.imgur.com/bz66x.png
Try these operations and check after each step if the problem is solved.
Put a backslash (\) before every ' in your strings.xml file
Clean and rebuild project, close Android Studio and run it again as administrator.
Delete AndroidStudio folder and reinstall it.

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.

Gradle sync failed: Cause: startup failed (Basic functionality not working)

It is my first time to use android studio V 3.1.3
when i finished installation and trying to build this error is shown
it said that "Basic functioality not working correctly such as building and debugging "
i do not known how to solve it
i use a local gradle distribution like this
Then press on sync project with gradles files
but this error is still shown.
It works well but after that this error is happened
any help
Thanks in advance.
I also have the same problems as you,Now I have solved it.
The following are the steps to be solved
Exit Android Studio.
Delete the .gradle folder eg: C:\Users{userName}}.gradle
Restart androidStudio and wait a moment.
Have you tried
Android studio -> File -> Invalidate Caches/Restart -> Invalidate and Restart
Deleting the .gradle folder was unsuccessfull for me.
Still waiting for another solution.
you should go to settings > build,execution,Deployment > build tool > gradle
and the change the user gradle home that to path of environment variable of JAVA-HOME Address
Like this
and then change gradle JDK to Embedded JDK it will solve your problem

Error: Finish can only be called once

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.

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

Categories

Resources