Java 代码在重新启动 Android studio 后转换为 XML

Java codes are converted to XML after restarting Android studio

由于 windows 冻结,我在 Android Studio 中的一些 java 代码被转换为一些奇怪的 xml 代码和我写的所有代码都丢失了!我两次遇到这种情况,第一次遇到这种情况时,我将代码恢复到上次提交,因为在上次提交后更改非常少。 然而这次在上次提交之后变化很大,我完全困惑了!

下面是我的一个小代码是怎么转换的

<component name="libraryTable">
  <library name="Gradle: com.android.support:print:28.0.0@aar">
    <ANNOTATIONS>
      <root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/87cddf7f66cc3e6d635cf04e7292a008/annotations.zip!/" />
    </ANNOTATIONS>
    <CLASSES>
      <root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/87cddf7f66cc3e6d635cf04e7292a008/res" />
      <root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/87cddf7f66cc3e6d635cf04e7292a008/jars/classes.jar!/" />
    </CLASSES>
    <JAVADOC />
    <SOURCES />
  </library>
</component>  

我的Android工作室版本:3.3.1

有什么办法可以找回我写的代码吗?

如有任何帮助,我们将不胜感激。

编辑

我又遇到了同样的情况。这是我用 xml

替换的另一个代码之一
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="AndroidConfiguredLogFilters">
    <filters>
      <filter>
        <option name="logLevel" value="verbose" />
        <option name="logMessagePattern" value="" />
        <option name="logTagPattern" value="(MainActivity|Download|BooksFrag|Reading|BookPage|BookDetails|PageNumberPicker)" />
        <option name="name" value="Unnamed-0" />
        <option name="packageNamePattern" value="" />
        <option name="pid" value="" />
      </filter>
    </filters>
  </component>
  <component name="AndroidLayouts">
    <shared>
      <config />
    </shared>
  </component>
  <component name="AndroidLogFilters">
    <option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Unnamed-0" />
  </component>
  <component name="ChangeListManager">
    <list default="true" id="0218df07-b316-45c7-a2ad-66ba2c0b4c43" name="Default Changelist" comment="">
      <change afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/utilities/RealmDBHelper.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/BookSearchResultsContainer.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/BookSearchResultsContainer.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/BookSearcher.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/BookSearcher.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/SearchOptions.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/SearchOptions.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/SearchResult.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/SearchResult.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/SearchResultViewHolder.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/SearchResultViewHolder.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/activities/ReadingActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/activities/ReadingActivity.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/utilities/ArabicUtilities.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/com/sed/maktaba_daar_al_hadeeth/utilities/ArabicUtilities.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/res/values/strings.xml" afterDir="false" />
    </list>
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="ExternalProjectsManager">
    <system id="GRADLE">
      <state>
        <projects_view />
      </state>
    </system>
  </component>
  <component name="FUSProjectUsageTrigger">
    <session id="1042793738">
      <usages-collector id="statistics.lifecycle.project">
        <counts>
          <entry key="project.closed" value="23" />
          <entry key="project.open.time.12" value="2" />
          <entry key="project.open.time.13" value="2" />
          <entry key="project.open.time.14" value="1" />
          <entry key="project.open.time.15" value="3" />
          <entry key="project.open.time.16" value="1" />
          <entry key="project.open.time.17" value="1" />
          <entry key="project.open.time.18" value="2" />
          <entry key="project.open.time.2" value="1" />
          <entry key="project.open.time.21" value="1" />
          <entry key="project.open.time.22" value="1" />
          <entry key="project.open.time.24" value="1" />
          <entry key="project.open.time.25" value="2" />
          <entry key="project.open.time.26" value="2" />
          <entry key="project.open.time.27" value="5" />
          <entry key="project.open.time.28" value="1" />
          <entry key="project.open.time.29" value="1" />
          <entry key="project.open.time.3" value="1" />
          <entry key="project.open.time.30" value="1" />
          <entry key="project.open.time.31" value="1" />
          <entry key="project.open.time.32" value="1" />
          <entry key="project.open.time.36" value="1" />
          <entry key="project.open.time.4" value="1" />
          <entry key="project.open.time.46" value="1" />
          <entry key="project.open.time.49" value="1" />
          <entry key="project.open.time.5" value="2" />
          <entry key="project.open.time.50" value="1" />
          <entry key="project.open.time.51" value="1" />
          <entry key="project.open.time.6" value="2" />
          <entry key="project.open.time.7" value="1" />
          <entry key="project.open.time.8" value="2" />
          <entry key="project.opened" value="44" />
        </counts>
      </usages-collector>
      <usages-collector id="statistics.file.extensions.open">
        <counts>
          <entry key="MF" value="1" />
          <entry key="css" value="4" />
          <entry key="csv" value="11" />
          <entry key="gradle" value="14" />
          <entry key="java" value="298" />
          <entry key="js" value="19" />

我记录了 Google here 的问题。

谢谢。

编辑(2019 年 11 月)

我在 android studio 3.5.2 中也遇到过这个问题。看来问题还没有解决。

别担心!

转到 android 位于 Users/user/.androidstudiov.x.x 的工作室文件夹 并删除您的缓存并重新启动 android 工作室。这个问题发生在我几天前,就在我升级到新版本之后。即使 XML 和 java 类 也会有这个。但是,您的所有数据都是安全的。 android studio 中的错误,正在导入设置..