Fixed
Status Update
Comments
da...@google.com <da...@google.com> #3
Bug is reproducible with 3.6 beta 1
da...@google.com <da...@google.com> #4
Dev note: The ends up going down a code path that existed before view binding, so it's querying data binding to see what the class should be:
private fun getViewClassName(viewName: String, layoutName: String?, facet: AndroidFacet): String? {
...
when {
...
SdkConstants.VIEW_STUB == viewName -> {
val mode = DataBindingUtil.getDataBindingMode(facet)
return mode.viewStubProxy
}
...
}
but data binding isn't enabled in this case, so we're getting back a class name of "" which gets converted to null which causes the crash here.
Should be easy to fix but I'll wait until Monday.
private fun getViewClassName(viewName: String, layoutName: String?, facet: AndroidFacet): String? {
...
when {
...
SdkConstants.VIEW_STUB == viewName -> {
val mode = DataBindingUtil.getDataBindingMode(facet)
return mode.viewStubProxy
}
...
}
but data binding isn't enabled in this case, so we're getting back a class name of "" which gets converted to null which causes the crash here.
Should be easy to fix but I'll wait until Monday.
da...@google.com <da...@google.com>
da...@google.com <da...@google.com> #5
This should be fixed in the next 4.0 canary, and it is being cherry picked into 3.6 (aiming for beta 4 I believe)
si...@gmail.com <si...@gmail.com> #6
Was this included in beta 4? We're running beta 5 now, and we still see the issue.
da...@google.com <da...@google.com> #7
It's been a while but it should have been in by beta 5. You're getting the exact same callstack?
da...@google.com <da...@google.com> #8
Oh yeah there's a test project. Let me try locally.
da...@google.com <da...@google.com> #9
I was not able to reproduce the issue using 3.6 beta 5. My repro steps:
- Extract test project (TestViewBinding.zip)
- Open in Studio 3.5 beta 5
- ("You must upgrade your Gradle plugin".... Accept and upgrade)
- Open Test.kt
- Press alt-enter on "Context"
- "import android.content.Context" is added without issue
si...@gmail.com <si...@gmail.com> #10
Not entirely sure ViewStubs are causing the issue for us. We've created a separate issue in https://issuetracker.google.com/issues/146115250 . I think we can continue the conversation there.
Description
In the attached project, note the stub_test.xml layout file
Open the Test.kt class and notice the missing Context import and that Context is highlight red
Place the cursor on Context and hit option-enter. Notice that an import doesn't get added for Context. After some time, or pressing it a few times, notice the IDE error.
Delete the stub_test.xml or add viewBindingIgnore="true" to it and notice that an import gets added for Context right away
Android Studio 3.6 beta1
java.lang.IllegalStateException: field must not be null
at com.android.tools.idea.databinding.cache.LayoutBindingShortNamesCache$3.compute(LayoutBindingShortNamesCache.kt:78)
at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
at com.intellij.util.CachedValueBase.lambda$getValueWithLock$1(CachedValueBase.java:240)
at com.intellij.openapi.util.RecursionManager$1.doPreventingRecursion(RecursionManager.java:113)
at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:71)
at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:241)
at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
at com.android.tools.idea.databinding.cache.LayoutBindingShortNamesCache.getFieldsByName(LayoutBindingShortNamesCache.kt:132)
at com.intellij.psi.search.PsiShortNamesCache.processFieldsWithName(PsiShortNamesCache.java:185)
at com.intellij.psi.impl.CompositeShortNamesCache.processFieldsWithName(CompositeShortNamesCache.java:238)
at org.jetbrains.kotlin.idea.core.KotlinIndicesHelper.getFieldsByNameUnfiltered(KotlinIndicesHelper.kt:355)
at org.jetbrains.kotlin.idea.core.KotlinIndicesHelper.getJavaCallables(KotlinIndicesHelper.kt:334)
at org.jetbrains.kotlin.idea.core.KotlinIndicesHelper.processJvmCallablesByName(KotlinIndicesHelper.kt:277)
at org.jetbrains.kotlin.idea.quickfix.ImportFix.collectMemberCandidates(ImportFix.kt:338)
at org.jetbrains.kotlin.idea.quickfix.ImportFix.fillCandidates(ImportFix.kt:368)
at org.jetbrains.kotlin.idea.quickfix.ImportFixBase.collectSuggestionsForName(ImportFix.kt:179)
at org.jetbrains.kotlin.idea.quickfix.ImportFixBase.collectSuggestions(ImportFix.kt:147)
at org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter$Companion.autoImport(KotlinReferenceImporter.kt:117)
at org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter$Companion.autoImportReferenceAtCursor(KotlinReferenceImporter.kt:95)
at org.jetbrains.kotlin.idea.quickfix.KotlinReferenceImporter.autoImportReferenceAtCursor(KotlinReferenceImporter.kt:43)
at com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl.autoImportReferenceAtCursor(DaemonCodeAnalyzerImpl.java:864)
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.lambda$letAutoImportComplete$1(ShowIntentionActionsHandler.java:104)
at com.intellij.openapi.command.impl.CoreCommandProcessor.runUndoTransparentAction(CoreCommandProcessor.java:377)
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.letAutoImportComplete(ShowIntentionActionsHandler.java:104)
at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.invoke(ShowIntentionActionsHandler.java:71)
at com.intellij.codeInsight.intention.actions.ShowIntentionActionsAction.actionPerformed(ShowIntentionActionsAction.java:50)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:265)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:82)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:148)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:280)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:593)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$3(IdeKeyEventDispatcher.java:646)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:192)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:645)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:508)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:463)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:212)
at com.intellij.ide.IdeEventQueue.lambda$new$5(IdeEventQueue.java:265)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:805)
at com.intellij.ide.IdeKeyboardFocusManager.dispatchEvent(IdeKeyboardFocusManager.java:40)
at java.awt.Component.dispatchEventImpl(Component.java:4770)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:739)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:736)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:878)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:805)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:466)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:465)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
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)