Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Android Studio keep toggling `languageLevel`?

Tags:

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">
like image 867
Ted Henry Avatar asked Jun 25 '18 21:06

Ted Henry


1 Answers

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.

like image 73
MatPag Avatar answered Sep 18 '22 11:09

MatPag