Android Studio 3.1.1 - unable to add module (impor

2019-03-25 16:03发布

问题:

Android Studio 3.1.1. New module -> Import gradle project, after I select project to import and confirm, IDE crashes with exception:

Element: class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file:///home/michal/AndroidStudioProjects/FirebaseJobTest/settings.gradle, content=VirtualFileContent{size=26}}(1416c50); SingleRootFileViewProvider{myVirtualFile=file:///home/michal/AndroidStudioProjects/FirebaseJobTest/settings.gradle, content=VirtualFileContent{size=26}}(665cfacf) invalidated at: see attachment com.intellij.psi.PsiInvalidElementAccessException: Element: class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file:///home/michal/AndroidStudioProjects/FirebaseJobTest/settings.gradle, content=VirtualFileContent{size=26}}(1416c50); SingleRootFileViewProvider{myVirtualFile=file:///home/michal/AndroidStudioProjects/FirebaseJobTest/settings.gradle, content=VirtualFileContent{size=26}}(665cfacf) invalidated at: see attachment at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:502)

Do you know any workaround?

回答1:

I was facing the same issue, seems like IDE issue, try manually adding

include ':app', ':your_module_name'

in settings.gradle and sync gradle, hope it helps.