Android Studio花费太长时间来构建项目,并且发生了错误

时间:2019-04-09 10:42:10

标签: android android-studio

我刚刚打开一个项目,它弹出了堆栈跟踪。之后,我等待构建完成,但是花费了很长时间(超过4个小时)。我在1个月前打开了同一项目,没有任何问题,而且我不确定问题来自何方。

Stacktrace:

java.lang.IllegalStateException: @NotNull method com/android/tools/idea/gradle/project/model/AndroidModuleModel.getRootDir must not return null
    at com.android.tools.idea.gradle.project.model.AndroidModuleModel.$$$reportNull$$$0(AndroidModuleModel.java)
    at com.android.tools.idea.gradle.project.model.AndroidModuleModel.getRootDir(AndroidModuleModel.java:571)
    at com.android.tools.idea.gradle.project.sync.setup.module.android.ContentRootsModuleSetupStep.findContentEntries(ContentRootsModuleSetupStep.java:71)
    at com.android.tools.idea.gradle.project.sync.setup.module.android.ContentRootsModuleSetupStep.doSetUpModule(ContentRootsModuleSetupStep.java:58)
    at com.android.tools.idea.gradle.project.sync.setup.module.android.ContentRootsModuleSetupStep.doSetUpModule(ContentRootsModuleSetupStep.java:41)
    at com.android.tools.idea.gradle.project.sync.setup.module.ModuleSetupStep.setUpModule(ModuleSetupStep.java:35)
    at com.android.tools.idea.gradle.project.sync.setup.module.common.BaseSetup.setUpModule(BaseSetup.java:41)
    at com.android.tools.idea.gradle.project.sync.ng.ModuleSetup.setupModuleModels(ModuleSetup.java:141)
    at com.android.tools.idea.gradle.project.sync.ng.CachedProjectModelsSetup.setUpModules(CachedProjectModelsSetup.java:116)
    at com.android.tools.idea.gradle.project.sync.ng.ProjectSetup$ProjectSetupImpl.setUpProject(ProjectSetup.java:82)
    at com.android.tools.idea.gradle.project.sync.ng.SyncResultHandler.onSyncSkipped(SyncResultHandler.java:164)
    at com.android.tools.idea.gradle.project.sync.ng.NewGradleSync.trySyncWithCachedGradleModels(NewGradleSync.java:219)
    at com.android.tools.idea.gradle.project.sync.ng.NewGradleSync.sync(NewGradleSync.java:165)
    at com.android.tools.idea.gradle.project.sync.ng.NewGradleSync.access$000(NewGradleSync.java:59)
    at com.android.tools.idea.gradle.project.sync.ng.NewGradleSync$2.run(NewGradleSync.java:151)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
    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.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:1)

尝试文件->使缓存无效/重新启动,它对我有用。