最近把AS升级到3.4.2版本后,发现项目通过 File -> Project Structure 后打开的Project Structure窗口无法显示项目的配置信息(这个问题在AS旧的版本,3.4之前没出现),如下图:
20190801-153003.png
点击AS右下角的感叹号图标:
20190801-154327.png
打开 IDE Fatal Errors 窗口
20190801-153031.png
发现有报错信息,如下:
cannot create configurable component
java.lang.IllegalStateException: Duplicate key 1.1.3
at com.android.tools.idea.gradle.dsl.model.ext.GradlePropertyModelImpl.lambda$getMap$2(GradlePropertyModelImpl.java:151)
at java.util.HashMap.merge(HashMap.java:1253)
at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1376)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.android.tools.idea.gradle.dsl.model.ext.GradlePropertyModelImpl.getMap(GradlePropertyModelImpl.java:150)
at com.android.tools.idea.gradle.dsl.model.ext.GradlePropertyModelImpl.extractValue(GradlePropertyModelImpl.java:534)
at com.android.tools.idea.gradle.dsl.model.ext.GradlePropertyModelImpl.getValue(GradlePropertyModelImpl.java:104)
at com.android.tools.idea.gradle.dsl.model.ext.GradlePropertyModelImpl.toMap(GradlePropertyModelImpl.java:472)
at com.android.tools.idea.gradle.structure.model.PsVariable$MapVariableEntries.getKeys(PsVariable.kt:209)
at com.android.tools.idea.gradle.structure.model.PsVariable$MapVariableEntries.getKeys(PsVariable.kt:203)
at com.android.tools.idea.gradle.structure.model.android.PsCollectionBase.refresh(PsCollectionBase.kt:43)
at com.android.tools.idea.gradle.structure.model.PsVariable.init(PsVariable.kt:43)
at com.android.tools.idea.gradle.structure.model.PsVariables.update(PsVariables.kt:41)
at com.android.tools.idea.gradle.structure.model.PsVariables.update(PsVariables.kt:23)
at com.android.tools.idea.gradle.structure.model.android.PsCollectionBase$refresh$2.accept(PsCollectionBase.kt:44)
at com.android.tools.idea.gradle.structure.model.android.PsCollectionBase$refresh$2.accept(PsCollectionBase.kt:23)
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at com.android.tools.idea.gradle.structure.model.android.PsCollectionBase.refresh(PsCollectionBase.kt:44)
at com.android.tools.idea.gradle.structure.model.PsVariables.<init>(PsVariables.kt:30)
at com.android.tools.idea.gradle.structure.model.PsProjectImpl.<init>(PsProjectImpl.kt:65)
at com.android.tools.idea.gradle.structure.configurables.GradleAndroidConfigurableContributor.getConfigurables(GradleAndroidConfigurableContributor.kt:31)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable$addConfigurables$configurables$1.invoke(ProjectStructureConfigurable.kt:330)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable$addConfigurables$configurables$1.invoke(ProjectStructureConfigurable.kt:81)
at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:279)
at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:267)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.addConfigurables(ProjectStructureConfigurable.kt:521)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.initSidePanel(ProjectStructureConfigurable.kt:320)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.createComponent(ProjectStructureConfigurable.kt:216)
at com.intellij.openapi.options.ex.ConfigurableCardPanel.lambda$createConfigurableComponent$0(ConfigurableCardPanel.java:73)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:973)
at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
at com.intellij.openapi.options.ex.ConfigurableCardPanel.createConfigurableComponent(ConfigurableCardPanel.java:69)
at com.intellij.openapi.options.ex.ConfigurableCardPanel.create(ConfigurableCardPanel.java:55)
at com.intellij.openapi.options.newEditor.ConfigurableEditor$1.create(ConfigurableEditor.java:57)
at com.intellij.openapi.options.newEditor.ConfigurableEditor$1.create(ConfigurableEditor.java:54)
at com.intellij.ui.CardLayoutPanel.createValue(CardLayoutPanel.java:88)
at com.intellij.ui.CardLayoutPanel.select(CardLayoutPanel.java:116)
at com.intellij.ui.CardLayoutPanel.select(CardLayoutPanel.java:101)
at com.intellij.openapi.options.newEditor.ConfigurableEditor.init(ConfigurableEditor.java:106)
at com.intellij.openapi.options.newEditor.SingleSettingEditor.<init>(SingleSettingEditor.java:29)
at com.intellij.openapi.options.newEditor.SettingsDialog.<init>(SettingsDialog.java:41)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable$showDialog$dialog$1.<init>(ProjectStructureConfigurable.kt:286)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.showDialog(ProjectStructureConfigurable.kt:286)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.showPlace(ProjectStructureConfigurable.kt:267)
at com.android.tools.idea.structure.dialog.ProjectStructureConfigurable.show(ProjectStructureConfigurable.kt:283)
at com.android.tools.idea.gradle.actions.AndroidShowStructureSettingsAction.showAndroidProjectStructure(AndroidShowStructureSettingsAction.java:62)
at com.android.tools.idea.gradle.actions.AndroidShowStructureSettingsAction.actionPerformed(AndroidShowStructureSettingsAction.java:53)
at com.intellij.openapi.actionSystem.impl.ChameleonAction.actionPerformed(ChameleonAction.java:58)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:258)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:275)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:287)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:283)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:106)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:277)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:111)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at com.apple.laf.ScreenMenuItemCheckbox.itemStateChanged(ScreenMenuItemCheckbox.java:193)
at java.awt.CheckboxMenuItem.processItemEvent(CheckboxMenuItem.java:389)
at java.awt.CheckboxMenuItem.processEvent(CheckboxMenuItem.java:357)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:355)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:343)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:767)
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:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.awt.EventQueue$4.run(EventQueue.java:735)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:755)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:704)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391)
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)
java.lang.IllegalStateException: Duplicate key 1.1.3,意思存在重复的key 1.13,然后就在项目中全局搜索,发现在项目中的build.gradle文件中存在重复的key 1.13,两个一样的
“ badgeview : '1.1.3', ”
20190801-15531.png
解决方法:去掉一个“ badgeview : '1.1.3', ”就可以了。
以上仅仅是我项目的Project Structure显示异常的解决过程,希望对遇到此类问题的你有所帮助。当然也许你遇到的Project Structure显示异常的情况和我不同,如果你解决了,诚谢你分享和告知,以便帮助到需要帮助的人。😊😊😊
网友评论