Getting error when trying to run new project in Android Studio 2.2.1
Solution 1:
Check your android build tools dependencies. In your build.gradle if its something like:
classpath "com.android.tools.build:gradle:+"
It has likely downloaded the alpha of 2.2 and that can cause the error you are seeing.
Try
classpath "com.android.tools.build:gradle:2.1.0"
If you are already using the right build tools version but keep getting this error, maybe one of the third party Android libraries you are using is causing the problem due to the same reason. You can force the dependency version to be used (including transitive) by changing
classpath "com.android.tools.build:gradle:2.1.0"
to
classpath('com.android.tools.build:gradle:2.1.0') {
force = true
}
Documentation: gist and official gradle docs.
Solution 2:
I was also facing same problem. I upgraded Android Studio and as it forced to But we need to configure same in App Settings as well.
Solution 3:
You can try to update JAVA_HOME to point to JDK 8 location.
In my case, I've updated Android studio project's SDK settings, changed java version in my PATH env variable, but still this error occured. Only updating JAVA_HOME helped me.
Solution 4:
I was also facing the same problem. I upgraded Android Studio and as it forced to install JDK 8, downloaded and installed this as well. But we need to configure same in App Settings as well.
- Select Project [Right click on the app module] -> Open Module Settings -> Select SDK Location from Left Menu - > Configured correct JDK Version i.e removed the old version and updated path of JDK. Save.
- Sync Project.
Problem solved!
EDIT: Elaborated Project word.
Solution 5:
If you are on Jenkins, check Java version in Jenkins->Manage Jenkins->Global Tool Configuration->JDK
I had to update mine to JDK 8.