Ted Henry
Ted Henry

Reputation: 1492

Why does Android Studio keep toggling `languageLevel`?

Very often, when I look at the git diff output for my Android app built with Android Studio, I see the following. Sometimes it is changing languageLevel from JDK_1_7 to JDK_1_8. Other times it is changing languageLevel from JDK_1_8 to JDK_1_7. Why so much indecision??

--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -24,7 +24,7 @@
       </value>
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">

Upvotes: 5

Views: 1299

Answers (1)

MatPag
MatPag

Reputation: 44831

1) Add this to your app build.gradle (inside the android element)

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

2) Exclude the .idea folder from Git adding this to your project level .gitignore

# Ignore idea folder
.idea/

then you need to refresh your versioned files following something like this

Versioning the .idea folder it's useful only to share some AS settings with your team, if you are working alone or if you don't have shared coding policies you can remove it.

Upvotes: 4

Related Questions