Gradle not building - android-studio

The following error occurs and none of my android projects sync with gradle. This occurred spontaneously when I opened android studio. My JAVA_HOME user variable is set to 'C:\Program Files\Java\jdk1.8.0_144\bin'. Also, JDK location in android studio wont change from F:\Softwares\Android\jre to anything because it changes back when I try to change it.
The newly created daemon process has a different context than expected.
Java home is differnt.
Expecting: 'F:\Softwares\Android\jre' but was: 'C:\Program
Files\JAVA\jdk1.8.0_144'. Please configure the JDK to match the expected one.

I changed the sdk and ndk location to somewhere else, so that the warnings for space in paths donot occur. Then I could change the JDK location inside android studio to 'C:\ProgramFiles\JAVA\jdk1.8.0_144'. This fixed the gradle problem.

Related

Invalid Gradle JDK configuration found. What is the best solution?

when i try to run an app written by others in a different PC in my android studio, i get this error message.
Invalid Gradle JDK configuration found. Open Gradle Settings
Use Embedded JDK (C:\Program Files\Android\Android2\jre)
Change JDK location.
I just want to run this in my AStudio and check the app. what is best and easiest recommendation..
Go to File > Project Structure and change JDK location to Embedded JDK You can use short key Ctr+Alt+Shift+S

Android studio is not opening AFTER changing studio64x.exe.vmoptions or deleting it

I have changed studio64x.vmoptions file to make studio faster but ever since I made change, android studio is not opening. it shows error about JAVA_HOME environment variable but I already have added that. please help!
tried reinstalling android studio, adding Java_Home , deleting studio64x.exe.vmoptions. still not opening
I was able to resolve the same issue (Android Studio was not opening) by refer to the solution provided in Android Developer Portal,
Studio doesn't start after upgrade
If Studio doesn't start after an upgrade, the problem may be due to an invalid Android Studio configuration imported from a previous version of Android Studio or an incompatible plugin. As a workaround, try deleting (or renaming, for backup purposes) the directory below, depending on the Android Studio version and operating system, and start Android Studio again. This will reset Android Studio to its default state, with all third-party plugins removed.
For Android Studio 4.1 and later:
Windows: %APPDATA%\Google\AndroidStudio Example: C:\Users\your_user_name\AppData\Roaming\Google\AndroidStudio4.1
macOS: ~/Library/Application Support/Google/AndroidStudio Example: ~/Library/Application Support/Google/AndroidStudio4.1
Linux: ~/.config/Google/AndroidStudio and ~/.local/share/Google/AndroidStudio Example: ~/.config/Google/AndroidStudio4.1 and ~/.local/share/Google/AndroidStudio4.1

Android Studio doesn't accept Android SDK Location

I've got a couple of years of Java experience but i'm new to Android Development. I installed Android Studio and on first launch it offers me to specify Android SDK Location in Settings/System Settings/Android SDK.
Android SDK is in C:\Program Files\AndroidSdk - so I:
Click Edit
Specify path C:\Program Files\AndroidSdk
Click Next
Then in Verify Setting menu button 'Next' is inactive so I click Finish
I'm back in Setting with same red message "Specify Android SDK Location".
N.B. I specified ANDROID_HOME = C:\Program Files\AndroidSdk
and added C:\Program Files\AndroidSdk\tools and C:\Program Files\AndroidSdk\tools\bin in PATH.
Maybe you have any idea why it doesn't take my SDK Location?
After you open Studio. Goto File->Project Structure
Then specify the correct SDK location.
You can verify in terminal or cmd whether the path you are providing there is actually reachable on your system. If not, it won't work.
I solved the problem! At first launch SDK Manager of Android Studio offers to install Android SDK on your PC, for this - specify EMPTY folder. I thought i had to give him the path to already existing SKD (non-empty folder) - that was the problem.
After specifying empty folder, everything had been installed successfully and seems to work fine.

Why doesn't Android Studio accept new Java JDK location

I am trying to change the JDK location from "C:\Program Files\Java\jdk1.7.0_09" to "C:\Program Files\Java\jdk1.8.0_25", but Android Studio seems to ignore the change completely. The location remains "C:\Program Files\Java\jdk1.7.0_09".
Could anyone offer a tip on how to remedy this?
I have tried many times and restarted AS a few times. I must be missing something fundamental.
Try this, may be work.
Android studio don't accept a SDK path that contains a whitespace.
In your SDK path, there is a white space between 'Program Files'. Therefore Android Studio showing the error. Solution- Try placing the SDK at 'C:\sdk'. Then change the SDK location in Project Structure.

Android Studio - Gradle sync error on gradle-diagnostics-X.X.X.jar

I've just updated Android Studio and I can't sync my project anymore.
The event log reports:
Gradle sync failed: /Applications/Android Studio.app/Contents/gradle/gradle-X.X.X/lib/plugins/gradle-diagnostics-X.X.X.jar (No such file or directory)
To solve the Gradle sync error, open gradle-wrapper.properties file and update the Gradle wrapper distribution version from:
distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-all.zip
To:
Android Studio 3.4
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Android Studio 2.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip
Android Studio 2.2 distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Android Studio 2.1 distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
Android Studio 2.0 distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Android Studio 1.5 distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Android Studio 1.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
You can find the latest Gradle wrapper version visiting:
https://services.gradle.org/distributions/
EDIT:
As a side note, as #SeBsZ suggests,
the official repository of the Android Gradle plugin switched from MavenCentral to jCenter (see Bintray blog post).
Make sure your project build.gradle file contains the new repository and the new classpath:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
This is not strictly related to the question problem, but since we are already migrating to the new IDE preview it's better to make sure everything is in place.
If, like me, you are using an older project then you might still be using the maven repository. Make sure you change the repositories in your top-level build.gradle from maven() to jcenter(). Then make sure you are using the correct dependency as well: classpath 'com.android.tools.build:gradle:1.3.0-beta1' for the new 1.3 preview.
For me helped to set chmod on the .gradle directory to 777. After this whole Android studio started working correctly.
I got the same issue after updating android studio to 3.4
I resolve this updatig gradle-wrapper.properties
I had
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I leave
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
and with this To solve the Gradle sync error.
This is the weirdest thing ever and I never expected it to work but this:
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip
worked and got everything fixed (it was the '\' after https). It does make sense since that is an actual link to a file.
check your .bash_profile file and make sure your GRADLE_HOME points to a valid path, if things were working and you face this issue after android studio update, chances are your gradle got updated too.
Here is the example of my gradle home in .bash_profile:
export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin
Had the same problem with a newly set up Android Studio 2.2.2, gradle wrapper 2.14.1. I loaded the project before i installed the needed android-23 library and installed java after Android Studio installation.
Error message in Android Studio 2.2.2:
Error:The specified Gradle distribution
'https://services.gradle.org/distributions/gradle-2.14.1-all.zip' does
not appear to contain a Gradle distribution.
Error message in cmd:
projectfolder> gradlew
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:34)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:25)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
When i used gradle from cmd however it worked
projectfolder> set PATH=%PATH%;C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> set GRADLE_HOME=C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> cd C:\projectfolder\
projectfolder> gradle
BUILD SUCCESSFUL
In cmd i see that the gradle versions and android sdk version were correct
C:\>set | find "JAVA_HOME"
JAVA_HOME=C:\Java\jdk1.8.0_111\
However in C:\Users\.AndroidStudio2.2\system\log\idea.log it said something else:
2016-11-29 16:04:10,597 [ 107684] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre
2016-11-29 16:04:10,597 [ 107684] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre
After messing up Android Studio config files i ended up reinstalling everything in correct order (Java, Android Studio, Project) and it worked.
I got the same issue after updating my android studio to 1.5
Here is my error stack trace.
Error:A problem occurred configuring root project 'Kargo'.
java.io.FileNotFoundException: /home/adiyatmubarak/Documents/android-studio/gradle/gradle-2.4/lib/plugins/gradle-diagnostics-2.4.jar (No such file or directory)
After I checked to the android studio instalation directory within gradle, my gradle was gradle-2.8 I don't know how to setup my android studio path location, but for temporary fix I just rename it to gradle-2.4 and my problem solved.

Resources