Android .idea / misc.xml的languageLevel标记不断更改JDK
由于我不知道的原因,languageLevel键从JDK_1_8更改为JDK_1_7。
The languageLevel key gets changed from JDK_1_8 to JDK_1_7 for reasons I am not aware.
可能会发生什么?
这是否与其他开发项目的开发人员的IDE有关?也许他们有另一个Android Studio设置?
Does this have something to do with the IDE of other developers working on the project? Maybe they have another Android Studio setting?
以下是我发现源代码管理下的文件发生变化后弹出的内容:
Here is what pops up after I notice files under source control have changed:
$ git diff
diff --git a/.idea/misc.xml b/.idea/misc.xml
index fbb6828..5d19981 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
这是我的gitignore以防万一。
This is my gitignore in case it matters.
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
如何继续使其保持单向或者其他?
How do I proceed so that it just stays one way or the other?
这让我疯了一会儿。我能够通过在我的 build.gradle
中明确设置java版本来修复它:
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
}
}
请注意,如果您使用的是 VERSION_1_7
,那么当您冷启动Android Studio或切换到另一个使用 VERSION_1_8
的项目,它将修改 .idea / misc.xml
以使用 JDK_1_8
。执行gradle sync会将其还原为使用 JDK_1_7
。如果您使用 VERSION_1_8
,则不会出现此问题。
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.