Gradle hangs on Executing tasks: [:android:generateDebugSources - android

Since updating my Mac OS X to El Capitan (and android studio from 1.5.1 to 2.x with all tools and sdks) I have problems with my libgdx-robovm game in Android Studio. When I'm doing Gradle Sync it always hangs on:
Executing tasks: [:android:generateDebugSources,
:android:generateDebugAndroidTestSources, :android:mockableAndroidJar,
:android:prepareDebugUnitTestDependencies,
:android-full:generateDebugSources,
:android-full:generateDebugAndroidTestSources,
:android-full:mockableAndroidJar,
:android-full:prepareDebugUnitTestDependencies]
Always. By hanging I mean it goes forever.
I've seen few topics with the same problem, but I cannot find any solution and I'm really frustrated. I've tried:
1) Made sure that I have zlib installed (s /usr/include/zlib.h),
2) In Global Gradle settings I've tried turning on "Offline work", but result is the same,
3) Clearing robovm and gradle cache,
4) Restarting Android Studio,
5) Updating Android Studio to the latest stable version,
6) I've tried latest gradle, but it only raised new problems, finally after getting rid of them I got to the same point (hanging),
7) Removing .gradle directory,
8) Removing contents of build directory,
9) Clean & Rebuild,
10) Invalidate & Restart - after restarting it's not hanging, but any operation (clean, rebuild, sync) hangs gradle again,
11) Tried older Android Studio (1.5.1),
12) Tried different gradle plugin versions: 1.2.3, 1.5.0, 2.0+
13) Tried different android build tools (22.0.1 and 23.x.x)
14) Compiling straight from console (with -d for more logs):
Few last lines:
11:17:41.891 [DEBUG]
[org.gradle.model.internal.registry.DefaultModelRegistry]
Transitioning model element 'tasks.tasks' to state GraphClosed.
11:17:41.891 [INFO]
[org.gradle.execution.TaskNameResolvingBuildConfigurationAction
]
Selected primary task 'tasks' from project : 11:17:41.893 [DEBUG]
[org.gradle.execution.taskgraph.DefaultTaskGraphExecuter] Timing:
Creating the DAG took 0.002 secs 11:17:41.894 [INFO]
[org.gradle.BuildLogger] All projects evaluated.
Configuring > 7/7 projects
(goes forever...)
edit:
The problem which probably caused this freeze was the fact that I had 2 subprojects for ios (robovm) and when I removed one of them it finally worked. This is only a problem for ios as for android 2 submodules wasn't an issue. I also had to update robovm to the latest version.

We had this problem in our shop after the last upgrade, but all we had to do was
Build > Clean Project
Build > Rebuild Project
try to run it, if it doesnt work then go to
File > Invalid Caches / Restart and select "Invalidate and Restart"
then close the project, reopen it and run it again.

delete .gradle file and after that
Build > Clean Project
Build > Rebuild Project
try to run it, if it doesnt work then go to
File > Invalid Caches / Restart and select "Invalidate and Restart"
then close the project, reopen it and run it again.

Try some of these too :
Delete manually all the build's outputs created.
In setting -> Build tools -> check for default gradle wrapper.
Remove extra gradles versions , keep the latest one in studio.
Invalidate and restart.
Hopefully this will solve your problem. :)

I overcome that issue by following way:
File:Settings >> Instant Run >> Disable instant run
and then
Invalidate cache and Restart

Related

Android Studio 3.3 Stuck at Project Setup:reading from cache

I have create module library with NDK. After updating Android Studio 3.3, open project on studio stuck on build project
Project Setup:reading from cache...
Every time needs to "Invalidate and Restart" android studio then after studio working.
I have try to delete .gradle folder but still facing this issue.
How can I solved this misbehavior of studio 3.3?
I don't have enough reputation to comment so I'll post this as an answer.
After you Invalidate and Restart have you tried Build->Clean Project and rebuilding then syncing again?
Have you tried restarting your computer to turn of any processes that may keep caches from clearing?
Have you tried upgrading your gradle version as well (inside your gradle-wrapper.properties)?
Have you checked if your gradle path is correct at File -> Settings -> Build, Execution, Deployment -> Gradle?
Have you tried locating your gradlew and doing a gradlew cleanBuildCache?
Have you tried removing the C:\Users\{Your Username}\.gradle\caches folder?
Have you tried disabling cache building altogether (will slow down your build and is not recommended)? To do this you have to go to your gradle.properties file and set android.enableBuildCache=false
Gradle caches are at
On macOS/Linux: $HOME/.gradle/caches/
On Windows: %USER_HOME%\.gradle/caches/
Try to delete those directories.
More about build caches is here: Android Studio Build Cache
Also, Disable configuration on demand in your gradle.properties file as shown below:
org.gradle.configureondemand=false
See: Known issues with the Android Gradle Plugin
Try Below approach:
Go to "
File -> Settings -> Build, Execution, Deployment -> Instant Run"
and just disable it.
With this Android Studio builds from scratch each time but it's better than not building it right.
open your project's gradle.perperties file and add settings:
org.gradle.configureondemand=false
restart your projects

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

Gradle Project sync failed Android Studio (e.g. editing, debugging) will not work

This is the first time i work with Android studio, and i'm facing this problem with says Cradle Project Sync Failed (e.g. editing, debugging) will not work properly.
Go to
Tools--> Android - > Sync Project with gradle
if it does nt work try
File -> Invalidate Cache and Restart

Gradle Project Sync failed in Android Studio 2.3.1

Upon reopening Android Studio after an improper shutdown, my gradle project sync failed and many errors like: "Failed to resolve: junit:junit:4.12" started showing up in the Event Log. Screenshot is given below.
I tried the following things to no avail:
Updated Android Studio to ver 2.3.1 and thus also the Gradle
I also had error for "Plugin Error: required plugin "xyz" is disabled" so i deselected all the plugins showing errors from settings and reselected them which removed the error.
Then i went to Files -> Invalidate caches/restart
What should i do?
UPDATE: After clicking on "Disable offline mode and sync project", this is what happened.
Here is a working solution..
Step 1)
In Android Studio go to File > Project Structure
there unticheck "Use Embedded JDK" and below choose your JDK location..
Step 2)
Go to file gradle > wrapper > gradle-wrapper-proparties
change gradle version to 3.5-all
Step 3)
close the project and reopen
From your first screenshot
Gradle is in offline mode, which means that it won't go to the network to resolve dependencies.
Go to Preferences > Gradle and uncheck "Offline work".
After that try cleaning the project and Re-running again?
What worked for me;
Go to Preferences > Gradle & uncheck "Offline work"
Goto File > Invalidate caches and restart.
The project would restart and can begin to install dependencies. Dont worry if it takes a time, that could be due to slow network. Just go and sip coffee while you wait ;)

Gradle project sync failed?

When I started up my project this morning it randomly gave me a message saying Gradle project sync failed. Basic Functionality(eg. editing, debugging) will not work properly. in Android Studio. I looked at other answers that people had put up for this problem but they haven't been working. I invalidated my chaches/restarted my project but no luck. I also deleted my .gradle folder from my project folder and still no luck. If any of you guys could help me that would be awesome! This didn't happen yesterday when I was working on the project or anything, I wonder why its happening now. Oh yea it also says this as a gradle message: Error:C:\Users\Dave\.gradle\caches\2.2.1\scripts\settings_ad4t0wp5ikihzl1y1o83b5sbw\SettingsScript\buildscript\cache.properties (The system cannot find the file specified) :
Thanks again for anyone who reads this/ can help!
There is a file - "cache.properties" that gradle creates for you, upon first time inception of any project. The path for this file is "~Home_Directory\.gradle\2.2.1\taskArtifacts". You may find this path in your home directory. So basically, this file - "cache.properties" is missing from the "taskArtifacts" folder.
One of the solution that worked for me is to copy file - "cache.properties" from any test project of yours to this project that's currently experiencing an issue.
Regards
I had to choose using the Default Gradle Wrapper instead of local.
<< SETTINGS -->/ BUILD TOOLS --> Gradle --> radio button switch... >>
It has helped me to fix the same problem.
I had experience similar sync failed problem with gradle based android project (in Android Studio 1.1.0). I solved this problem without deleting .gradle from my user directory,
steps I followed was
Go to File -> Settings -> Compiler(Gradle Based Android Project)
Change VM options to -Xmx512m -XX:MaxPermSize=512m.
Click Apply -> OK and then tap on Try Again option in sync failed message to clean build the project.
Works like charm!!
UPDATE - 1 : For Android Studio 1.3, Compiler option mentioned in above Step-1 is present inside tab Build, Execution, Deployment.
I had faced similar kind of problem earlier!
But don`t know after rebuild the project and cleaning it, it worked normally.
Invalidate dependency cache by running
gradle clean build --refresh-dependencies
from project root and then re-import your project. Worked for me once.
May be you have put Android Studio into offline mode. To fix it, go to Preferences -> Gradle and ensure that the "Offline work" checkbox is not checked.
Than do
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio let it download all the Gradle stuff it needs
android studio 0.4.2: Gradle project sync failed error
Delete the folder C:\Users\.gradle and reopening the android studio solved my problem

Categories

Resources