Syntax highlighting gone in Android Studio 3.3.1 - android-studio

Recently, syntax highlighting stopped working for me in Android Studio.
And I believe it's related to my project and not Android Studio itself.
From my understanding, the below error message gets thrown when I open certain files and the syntax highlighting isn't executed. If I edit the file by removing a line of code or so, however, syntax highlighting will show up again.
Going through and searching for the stacktrace doesn't give me any real indicator on what might be wrong, so here I am. Do you know what might be wrong?
I've tried clearing caches, reinstalling and playing with different settings in Android Studio without any effect, which leads me to believe that this is related to the project directly. Moreover, if I create a new project, syntax highlighting works as normal.
What I see...
Full stacktrace...
org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassMemberMatchingError$NoMatch: Couldn't match ClsMethodImpl:hashCode MemberIndex(index=10) (with 0 parameters)
at org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassDataHolder.assertMatches(LazyLightClassDataHolder.kt:145)
at org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassDataHolder.access$assertMatches(LazyLightClassDataHolder.kt:32)
at org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassDataHolder$LazyLightClassData$getOwnMethods$$inlined$map$lambda$1.invoke(LazyLightClassDataHolder.kt:138)
at org.jetbrains.kotlin.idea.caches.lightClasses.LazyLightClassDataHolder$LazyLightClassData$getOwnMethods$$inlined$map$lambda$1.invoke(LazyLightClassDataHolder.kt:100)
at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
at org.jetbrains.kotlin.asJava.elements.KtLightMemberImpl.getClsDelegate(KtLightMemberImpl.kt)
at org.jetbrains.kotlin.asJava.elements.KtLightMemberImpl$_modifierList$2.invoke(KtLightMemberImpl.kt:47)
at org.jetbrains.kotlin.asJava.elements.KtLightMemberImpl$_modifierList$2.invoke(KtLightMemberImpl.kt:35)
at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)
at org.jetbrains.kotlin.asJava.elements.KtLightMemberImpl.get_modifierList(KtLightMemberImpl.kt)
at org.jetbrains.kotlin.asJava.elements.KtLightMemberImpl.getModifierList(KtLightMemberImpl.kt:52)
at org.jetbrains.kotlin.asJava.elements.KtLightMethodImpl.getModifierList(KtLightMethodImpl.kt:127)
at com.intellij.codeInsight.AnnotationUtil.isAnnotated(AnnotationUtil.java:244)
at com.intellij.codeInsight.AnnotationUtil.lambda$isAnnotated$4(AnnotationUtil.java:234)
at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449)
at com.intellij.codeInsight.AnnotationUtil.isAnnotated(AnnotationUtil.java:234)
at com.intellij.codeInsight.MetaAnnotationUtil.isMetaAnnotated(MetaAnnotationUtil.java:154)
at com.intellij.execution.junit.JUnitUtil.lambda$isJUnit5TestClass$1(JUnitUtil.java:280)
at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:140)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:87)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:139)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:126)
at com.intellij.execution.junit.JUnitUtil.isJUnit5TestClass(JUnitUtil.java:276)
at com.intellij.execution.junit.JUnit5Framework.isTestClass(JUnit5Framework.java:52)
at com.intellij.testIntegration.JavaTestFramework.isTestClass(JavaTestFramework.java:64)
at com.intellij.codeInsight.TestFrameworks.computeFramework(TestFrameworks.java:92)
at com.intellij.codeInsight.TestFrameworks.lambda$detectFramework$0(TestFrameworks.java:63)
at com.intellij.psi.util.CachedValuesManager.lambda$getCachedValue$0(CachedValuesManager.java:140)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:60)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:87)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:139)
at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:126)
at com.intellij.codeInsight.TestFrameworks.detectFramework(TestFrameworks.java:62)
at org.jetbrains.kotlin.idea.core.platform.impl.JvmIdePlatformKindTooling.getTestIcon(JvmIdePlatformKindTooling.kt:60)
at org.jetbrains.kotlin.idea.highlighter.KotlinTestRunLineMarkerContributor.getInfo(KotlinTestRunLineMarkerContributor.kt:66)
at com.intellij.execution.lineMarker.RunLineMarkerProvider.getLineMarkerInfo(RunLineMarkerProvider.java:46)
at com.intellij.codeInsight.daemon.impl.LineMarkersPass.queryProviders(LineMarkersPass.java:174)
at com.intellij.codeInsight.daemon.impl.LineMarkersPass.lambda$doCollectInformation$3(LineMarkersPass.java:96)
at com.intellij.codeInsight.daemon.impl.Divider.divideInsideAndOutsideInOneRoot(Divider.java:80)
at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:91)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:69)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$null$1(PassExecutorService.java:423)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1164)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:416)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:415)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:391)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:147)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:222)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:389)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:161)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Naturally when posting about an issue, the solution reveals itself shortly thereafter.
I have equals & hashcode overridden in one class (Entity) and both methods are marked as final. The issue comes up whenever a data-class extends Entity, Im guessing because its trying to create its own equals & hashcode methods, but cant.
Hope this helps anyone else out there! I think the behavior is correct (a data class has a very specific equals/hashcode) so I dont consider this a bug in the Kotlin plugin, but a better error message would be preferrable in the future.

Related

Is there a way of avoiding this error message? "Couldn't resolve resource #string/todo Tip: Try to refresh the layout."

I'm creating drafts of an app and I keep receiving the aforementioned error on numerous iterations. I feel like I might have mistakenly revalued the relevant string within the JRE / JDK somehow but I'm not 100% sure
I'm new to the game but have followed all recommended actions within Android Studio help prompts. And it keeps creating new strings within res->values->strings
not sure which section of code to include here
I expect this not to be an issue but it keeps reoccuring.
Please try adding a string resource in strings.xml at
<string name="todo">TODO</string>
The file is located at res/values/strings.xml.
Then rebuild the Android project through Ctrl+F9 key combination.

ADB debugging in Android Studio - some basic issues

Ok, I've squeaked by not needing to use ADB in the Studio, since back
in the 'beta' days of AS. (Just lucky, I guess.) But now, I need to
debug a crashing app.
I've gotten this far:
Learned how to put adb.exe on my Window's 'PATH'
(so that it's invokable from cmd-window):
My path-entry was: C:\Users\David\AppData\Local\Android\sdk\platform-tools
Am assuming that 'logcat' lives on Android device (I was incorrectly guessing it lives on the development machine). I'm assuming this, because when I dis-connect
the USB-cable and enter 'adb logcat' is says waiting for device.
Ok, now my (next) issue: When I fire up the app-being-developed, I'm getting
"Unfortunately has stopped"...which I'm assuming is an app-crash.
And, while I'm looking at 'logcat', I can see a stack-trace flow by. But
as I try to scroll-back to read it, logcat keeps dribbling in more data.
So, how do I tell it to shutup...so that I can look at a static copy
of logcat and see what has happened (without more data dribbling in)?
[If there is other beginner related info, beyond this question, feel free to
to add that info...I'm clearly in need of basic 'adb-related' enlightenment.]
TIA.
Cheers...

Loadframe Fails at CreateEx for no apparent reason in CMainFrame

Okay so my MFC application was working fairly well until I cleared the application from the system registry. Now I am unable to run the program. Whenever I try running the program I get an exception. Checking the stack I noticed that CreateEx in LoadFrame for CMainFrame was crushing. This crash occurs when ProcessShellCommand is called in the derived CwinApp of the application.However, I have not been able to pinpoint the exact cause of the crash. I have a hunch it might have something to do with the loading of resource but I don't know exactly how. I have checked the .rc include file and it looks fine to me. I just don't understand how clearing the registry could cause such a mess. Been at it for the past 4 hours.
So basically I am asking if any of you have faced this problem before, and how did you managed to fix it without starting right from scratch? I am not sure of the exact part of the code I should put here to clarify my question so I hope this is clear enough.
Thanks

Build is producing a .momd in the bundle that is missing the .mom file

I have an app that has been running fine on the iPhone simulator for some time. Recently, I decided I wanted to re-use the data model and related classes in another project - so I dragged them from this project window to the other then told Xcode not to copy, just to make references. At first this didn't work so I jumped through a number of hoops to try to fix it (I may be asking more about that in another post). After all this, I re-compiled and tried to run the original app -- and it's not working any more. On further investigation, I discovered that when I re-compile the original app, I end up with a bundle that contains a .momd package but it contains only a Versioninfo.plist file - no .mom file, no .omo file like I'm expecting to see. I don't recall making any changes to the original app. I don't get any warnings. I just get an incomplete .momd package (and, not surprisingly, my app now crashes).
What's going on here?
BTW, the app now crashes with this message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
Which I get when executing this line of code:
self.productRegistry = [[UIManagedDocument alloc] initWithFileURL:self.productRegistryURL];
I figured this out by looking more closely at the file locations in the project directory using Finder. In the Xcode window, everything looks normal but in the actual project directory I found that the .datamodeld package had ended up at the top level of the project directory -- at the same level as the project package itself. Xcode apparently did not like this but unfortunately it did not complain -- it just created a partial build output. Once I moved the .datamodeld package into the same folder as the rest of the project's code, everything worked just fine.
This would appear to be just a quirk. I would expect that Xcode would either see that all is well and build correctly OR it would see that things weren't quite as they should be and fail. In this case, it did not build correctly but was silent about it.
Hope this answer helps someone else someday.

DoNotChange was not found when adding new files

When I attempt to add a new file to the solution -- even a general C# empty class, I get an error:
The requested value 'DoNotChange' was not found. See screenshot.
This just started happening yesterday. I installed the monotouch-4.0.0.dmg, but have since rolled back to 3.2.6, but the problem remains.
I think there may be a fairly widespread issue, as this new StackOverflow question seems eerily similar.
Anyone have any ideas on how to recover?
Environment:
MonoTouch Professional 3.2.6 (4.0.0)
MonoDevelop 2.4.2 release 20402004
OSX 10.6.7
UPDATE: On a whim I tried to create a new empty .cs file outside of MT, and then add it to the project -- that worked, so at least there is a temporary workaround.
It looks like your formatting policy options are triggering a bug in the code formatter. Try resetting it by removing the file ~/.config/MonoDevelop/DefaultPolicies.xml

Resources