我在使用Android Studio(v2.3.3,建于2017-06-06)时遇到了一个奇怪的问题。我的一个Java文件被替换为似乎由Android Studio生成的无关XML。我不认为我做了任何事情来触发它。第二个Java文件很快就遭遇了同样的命运,再一次没有明显的原因。
幸运的是,我刚刚删除了源代码的副本,因此我删除了文件并替换了它们。我没有完整的奇怪代码副本,但我在git.moeryn.com找到的代码非常接近我所看到的:
<application>
<component name="UsageTrigger">
<counts>
<entry feature="CreateFile.CreateFileAction" count="1" />
<entry feature="JSDebugConfig.Debug.browser-default.preferredBrowser-null.no_mappings" count="6" />
<entry feature="OpenInBrowser.Opera" count="1" />
<entry feature="execute.Application.Coverage" count="1" />
<entry feature="execute.Application.Debug" count="1" />
<entry feature="execute.Application.Run" count="15" />
<entry feature="execute.GWT.ConfigurationType.Debug" count="12" />
<entry feature="execute.GWT.ConfigurationType.Run" count="18" />
<entry feature="execute.GroovyScriptRunConfiguration.Debug" count="1" />
<entry feature="execute.GroovyScriptRunConfiguration.Run" count="9" />
<entry feature="execute.JUnit.Coverage" count="4" />
<entry feature="execute.JUnit.Run" count="86" />
<entry feature="execute.JavascriptDebugType.Debug" count="6" />
<entry feature="ide.settings.Appearance" count="4" />
<entry feature="ide.settings.Colors_&_Fonts" count="1" />
<entry feature="ide.settings.Console_Font" count="4" />
<entry feature="ide.settings.Font" count="4" />
<entry feature="ide.settings.General" count="1" />
<entry feature="ide.settings.Gerrit" count="4" />
<entry feature="ide.settings.Java" count="1" />
<entry feature="ide.settings.Keymap" count="12" />
<entry feature="ide.settings.Vim_Emulation" count="2" />
<entry feature="idea.caches.invalidated" count="1" />
<entry feature="ideaapp.started" count="28" />
<entry feature="terminal.linux" count="2" />
<entry feature="uml.ShowDiagram.JAVA" count="1" />
<entry feature="welcome.screen.WelcomeScreen.Configure" count="1" />
<entry feature="welcome.screen.WelcomeScreen.CreateNewProject" count="2" />
</counts>
</component>
</application>
我在StackOverflow上找到了一个上周遇到类似问题的人:My Activity Class turn into an xml file但是,没有解决或解释发生了什么。我发现了另一个遇到同样问题的人:Android Studio wrong load a source file
现在它第三次发生在我身上 - 这次它影响了res / anim中的XML文件。这真是令人费解(而且令人担忧,因为我现在变得偏执,它会再次发生)。奇怪的是,文件内容在标签的中途被切断:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AnalysisUIOptions">
<option name="SCOPE_TYPE" value="3" />
</component>
<component name="AndroidLayouts">
<shared>
<config>
<devices>
<device id="Nexus 6" />
<device id="pixel" />
<device id="Nexus 4" />
<device id="tv_720p" />
<device id="tv_1080p" />
<device id="wear_round_chin_320_290" />
<device id="Galaxy Nexus" />
<device id="Nexus One" />
</devices>
</config>
</shared>
</component>
<component name="AndroidLogFilters">
<option name="TOOL_WINDOW_LOG_LEVEL" value="verbose" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="Show only selected application" />
</component>
<component name="BookmarkManager">
<bookmar
当我打开XML文件时,它发生了几次。 transition__dialog__slide_out_to_right.xml 被我之前正在处理的FlagView.java类的开头所取代(请注意,Java文件当时没有打开,它已经是2我编辑后的几个小时,而且这段代码不在剪贴板中:
package co.company.app.views;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatDelegate;
import android.util.AttributeSet;
import android.
transition__dialog__slide_in_from_right.xml 被这个部分XML取代:
<application>
<component name="UsageTrigger">
<counts>
<entry feature="CreateFile.CreateFileAction" count="2" />
<entry feature="execute.AndroidRunConfigurationType.Debug" count="14" />
<entry feature="execute.AndroidRunConfigurationType.Run" count="2237" />
<entry feature="execute.GradleRunCon
其他过渡动画文件正常打开。但是, res / anim 中的另一个文件被我的大多数加拿大国旗可绘制XML文件替换:
<!-- Canadian flag -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="24dp"
android:viewportWidth="1000.0"
android:viewportHeight="500.0">
<!-- Background red rectangle -->
<path
android:fillColor="#f00"
android:pathData="M 0,0 L 1000,0 L 1000,500 L 0,500"
/>
<!-- Center white square -->
<path
android:fillColor="#fff"
android:pathData="M250,0 H750 V500 H250"
/>
<!-- Maple leaf -->
<path
android:fillColor="#ff0000"
android:pathData=
"
M 499.992280, 46.87500
-34.113120, 63.62529
c -3.870860, 6.91501
-10.806270, 6.27363
-17.741690, 2.41138
l -24.696990, -12.78858
18.407050, 97.72711
c 3.870860, 17.85419
-8.548590, 17.85419
-14.67765, 10.13435
l -43.101050, -48.25099
-6.997380, 24.50300
c -0.806920, 3.21777
-4.354810, 6.59744
-9.677480, 5.79261
l -54.501770, -11.45912
14.315240, 52.04475
c 3.064510, 11.58054
5.454900, 16.37528
-3.09375, 19.42959
l -19.426190, 9.13025
93.821270, 76.20838
c 3.713500, 2.88151
5.589710, 8.06700
4.267680, 12.76210
l -8.211360, 26.94707
c 32.304050, -3.72371
61.248980, -9.32594
93.569390, -12.77619
2.853230, -0.30459
7.629880, 4.40408
7.610290, 7.71058
l -4.280240, 98.72342
15.706390, 0
-2.472370,
非常离奇...
我关闭了Android Studio,当我重新打开它时,它使用默认的灯光主题而不是我的黑暗主题。屏幕右侧出现错误列表。我关闭了应用程序并重新打开它。这次我得到一个弹出窗口,说“开始失败”:
Internal Error. Please report to https://code.google.com/p/android/issues
com.intellij.ide.plugins.PluginManager$StartupAbortedException: Fatal error initializing 'com.intellij.psi.PsiDocumentManager'
at com.intellij.ide.plugins.PluginManager.handleComponentError(PluginManager.java:248)
at com.intellij.openapi.components.impl.PlatformComponentManagerImpl.handleInitComponentError(PlatformComponentManagerImpl.java:43)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:536)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:119)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:103)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:90)
at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:285)
at com.intellij.openapi.project.impl.ProjectManagerImpl.initProject(ProjectManagerImpl.java:222)
at com.intellij.openapi.project.impl.ProjectManagerImpl.lambda$getDefaultProject$2(ProjectManagerImpl.java:280)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:494)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:443)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:198)
at com.intellij.openapi.project.impl.ProjectManagerImpl.getDefaultProject(ProjectManagerImpl.java:277)
at com.intellij.ide.fileTemplates.FileTemplateManager.getDefaultInstance(FileTemplateManager.java:67)
at com.android.tools.idea.startup.AndroidStudioInitializer.setUpNewProjectActions(AndroidStudioInitializer.java:270)
at com.android.tools.idea.startup.AndroidStudioInitializer.run(AndroidStudioInitializer.java:97)
at com.android.tools.idea.AndroidInitialConfigurator.activateAndroidStudioInitializerExtensions(AndroidInitialConfigurator.java:198)
at com.android.tools.idea.AndroidInitialConfigurator.<init>(AndroidInitialConfigurator.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:220)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.getComponentInstance(CachingConstructorInjectionComponentAdapter.java:58)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:495)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:119)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$createComponents$8(ApplicationImpl.java:429)
at com.intellij.openapi.progress.impl.CoreProgressManager$3.run(CoreProgressManager.java:170)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:494)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:443)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:155)
at com.intellij.openapi.application.impl.ApplicationImpl.createComponents(ApplicationImpl.java:436)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:103)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:392)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:384)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:196)
at com.intellij.idea.MainImpl$1.lambda$null$0(MainImpl.java:47)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:358)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.intellij.openapi.util.ActionCallback
at com.intellij.openapi.application.impl.LaterInvocator.invokeLater(LaterInvocator.java:137)
at com.intellij.openapi.application.impl.ModalityInvokatorImpl.invokeLater(ModalityInvokatorImpl.java:46)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeLater(ApplicationImpl.java:379)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeLater(ApplicationImpl.java:369)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeLater(ApplicationImpl.java:364)
at com.intellij.psi.impl.DocumentCommitThread.<init>(DocumentCommitThread.java:100)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:220)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.getComponentInstance(CachingConstructorInjectionComponentAdapter.java:58)
at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.getComponentInstance(ServiceManagerImpl.java:232)
at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:246)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.picocontainer.defaults.ImmutablePicoContainerProxyFactory.invoke(ImmutablePicoContainerProxyFactory.java:73)
at com.sun.proxy.$Proxy43.getComponentInstance(Unknown Source)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:217)
at org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:77)
at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:114)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:257)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:217)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.getComponentInstance(CachingConstructorInjectionComponentAdapter.java:58)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:495)
... 54 more
Android Studio似乎出现了严重错误......
答案 0 :(得分:0)
我没有发现问题的根本原因,但是根据Yashasvi的提示和Android Studio v3发布的幸运时间(我在2017-10-25上的问题前5天),我升级了软件,一切都已经过了从那时起工作正常。
对我的问题不是最令人满意的结论,但我的代码并没有搞砸,我很高兴。