Gradle error: Write access is allowed from event dispatch thread only in Android Studio

AndroidAndroid StudioGradleAndroid Gradle-PluginGradlew

Android Problem Overview


After updating Android Studio to version 2.2 (on Windows 10) and somehow next morning I received such error when gradle built on any project:

> Write access is allowed from event dispatch thread only

Despite that gradlew -build command worked and completed successfully. I tried typical Android dev's of WTF repairing set: clean build, invalidate caches, removing build folders, removing .gradle folder, tried different gradle settings, even reinstalling Android Studio and nothing helped.

I've created this question only to share my experience with community, because I wasted two hours on it.

Android Solutions


Solution 1 - Android

So the problem was concluded in that Android Studio conflicted with my installed JDK version, so it was resolved when I checked JDK location (File → Project Structure → SDK Location), ticked 'Use embedded JDK' checkbox and set JDK location to 'path to Android Studio'\Android Studio\jre

Solution 2 - Android

> Problem was occurred when android studio conflict with installed jdk > version, Go to the (File -> Project Structure -> SDK Location), check > 'Use embedded JDK' checkbox and set jdk location to 'path to android > studio'\Android Studio\jre :) Simple

Solution 3 - Android

that didn't work for me, i ran a 'gradle clean build' command, i figured out that there's a conflict in a line in the gradle, deleted it and sync project (as in this pic)

enter image description here

Solution 4 - Android

My issue was that I had removed the SDK I was using while clearing up hard drive space.

To fix this, first check what SDKs you have installed, or install one in Tools > SDK Manager.

You can then change the compileSdkVersion and targetSdkVersion in app build.gradle to your installed sdk version.

Otherwise you can just reinstall what ever sdk you were using.

Solution 5 - Android

In Android Studio 3.2.1 go to File -> Project Structure -> SDK Location and check in the check box "Use embedded JDK (recommended)". enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBelooView Question on Stackoverflow
Solution 1 - AndroidBelooView Answer on Stackoverflow
Solution 2 - AndroidNull Pointer ExceptionView Answer on Stackoverflow
Solution 3 - AndroidRyuzakiView Answer on Stackoverflow
Solution 4 - AndroidMatthew MullinView Answer on Stackoverflow
Solution 5 - AndroidAndy LuisView Answer on Stackoverflow