Android .idea/misc.xml's languageLevel tag keeps changing JDKs Android .idea/misc.xml's languageLevel tag keeps changing JDKs java java

Android .idea/misc.xml's languageLevel tag keeps changing JDKs


This was driving me nuts for a while. I was able to fix it by explicitly setting the java version in my build.gradle:

android {    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_7        targetCompatibility JavaVersion.VERSION_1_7    }}

Note that if you're using VERSION_1_7, when you cold launch Android Studio or switch to another project that uses VERSION_1_8, it will modify .idea/misc.xml to use JDK_1_8. Doing a gradle sync will revert it back to using JDK_1_7. If you're using VERSION_1_8, you won't have this issue.

It's not perfect but I found this to be good enough for now.


Came here from Google after updating to Android Studio 2.2. This might be helpful to others.

Since Android Studio 2.2, the JDK has been bundled with it, instead of you having to download and install it on your system. My project JDK started switching when I updated to 2.2, possibly because of the confusion between the two versions available now - system and embedded.

If you go into File > Project Structure (Mac OS), on the SDK Location tab, there is JDK location. There's now a new setting to use the embedded JDK. Once I switched to it, it solved my issue.

enter image description here


It seems the file should be stored under version control. I would propose to keep it in git, but ignore all local changes:

git update-index --assume-unchanged .idea/misc.xml

When switching branches there might be conflict in these files. Then you could use following imlreset script to reset the files:

#!/bin/bash                                                                     while read f                                                                    do                                                                                [ -f $f ] && git checkout $f                                                    done <<!                                                                        app/app.iml                                                           wear/wear.iml                                                                   !

Create similar script for ignoring these files if you do it often.