Android Studio 3.0 Gradle同步失败:java.lang.AssertionError(在UnresolvedDependenciesReporter中)

时间:2017-08-11 16:57:48

标签: android android-studio android-gradle

迁移到Android Studio 3.0-beta1时,我遇到了gradle sync failed错误,但没有提供太多信息。 gradle控制台中没有错误消息。我不得不去idea.log文件获取以下堆栈跟踪:

java.lang.RuntimeException: java.lang.AssertionError
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:174)
    at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:155)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.ModuleModelDataService.importData(ModuleModelDataService.java:80)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.ModuleModelDataService.importData(ModuleModelDataService.java:50)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.doImportData(ProjectDataManager.java:246)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:143)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:198)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:204)
    at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doSelectiveImport(IdeaSyncPopulateProjectTask.java:206)
    at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:156)
    at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access$000(IdeaSyncPopulateProjectTask.java:51)
    at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask$1.run(IdeaSyncPopulateProjectTask.java:144)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:726)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:176)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:137)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:334)
    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)
Caused by: java.lang.AssertionError
    at com.android.tools.idea.gradle.project.sync.issues.UnresolvedDependenciesReporter.report(UnresolvedDependenciesReporter.java:79)
    at com.android.tools.idea.gradle.project.sync.issues.SyncIssuesReporter.report(SyncIssuesReporter.java:86)
    at com.android.tools.idea.gradle.project.sync.issues.SyncIssuesReporter.report(SyncIssuesReporter.java:71)
    at com.android.tools.idea.gradle.project.sync.setup.module.android.DependenciesAndroidModuleSetupStep.doSetUpModule(DependenciesAndroidModuleSetupStep.java:98)
    at com.android.tools.idea.gradle.project.sync.setup.module.android.DependenciesAndroidModuleSetupStep.doSetUpModule(DependenciesAndroidModuleSetupStep.java:64)
    at com.android.tools.idea.gradle.project.sync.setup.module.ModuleSetupStep.setUpModule(ModuleSetupStep.java:34)
    at com.android.tools.idea.gradle.project.sync.setup.module.AndroidModuleSetup.setUpModule(AndroidModuleSetup.java:44)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.AndroidModuleModelDataService.setUpModule(AndroidModuleModelDataService.java:93)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.AndroidModuleModelDataService.importData(AndroidModuleModelDataService.java:79)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.ModuleModelDataService$1.run(ModuleModelDataService.java:78)
    at com.intellij.openapi.command.WriteCommandAction$Simple.run(WriteCommandAction.java:234)
    at com.intellij.openapi.application.RunResult.run(RunResult.java:35)
    at com.intellij.openapi.command.WriteCommandAction.lambda$null$1(WriteCommandAction.java:171)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1023)
    at com.intellij.openapi.command.WriteCommandAction.lambda$performWriteCommandAction$2(WriteCommandAction.java:170)
    at com.intellij.openapi.command.WriteCommandAction.lambda$doExecuteCommand$4(WriteCommandAction.java:210)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:149)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:119)
    at com.intellij.openapi.command.WriteCommandAction.doExecuteCommand(WriteCommandAction.java:212)
    at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:168)
    at com.intellij.openapi.command.WriteCommandAction.lambda$execute$0(WriteCommandAction.java:155)
    at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransactionAndWait$2(TransactionGuardImpl.java:163)
    at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:86)
    at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:109)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:410)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
    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.awt.EventQueue.dispatchEvent(EventQueue.java:732)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:827)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:655)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
    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)

我关注了migration documentation,但仍然无法让同步成功运行。不确定这是Android Studio 3.0-beta1或我的项目配置中的问题。我已经运行了其他项目,并使用Android Studio 3.0-alphaX创建了新项目,因此我倾向于我的项目。

10 个答案:

答案 0 :(得分:12)

问题是我没有为缺少的构建类型选择默认值。我的项目有2个模块,具有以下构建类型配置:

数据/的build.gradle

apply plugin: 'com.android.library'
android {
    ...
    buildTypes {
        debug { ... }
        release { ... }
    }
}

应用程序/的build.gradle

apply plugin: 'com.android.application'
android {
    ...
    buildTypes {
        debug { ... }
        dev { ... }
        qa { ... }
        rc { ... }
        release { ... }
    }
}

使用最新的Android gradle插件,您的构建类型必须匹配库到应用程序模块。我的问题是我的数据模块没有定义devqarc构建类型。我在我的应用程序模块中使用buildTypeMatching解决了这个问题:

应用程序/的build.gradle

apply plugin: 'com.android.application'
android {
    ...

    buildTypeMatching 'dev', 'debug'
    buildTypeMatching 'qa', 'debug'
    buildTypeMatching 'rc', 'release'

    buildTypes {
        debug { ... }
        dev { ... }
        qa { ... }
        rc { ... }
        release { ... }
    }
}

您也可以将缺少的变体添加到库模块中。

我遇到了bug report这似乎是同一个问题。看起来错误消息中有一个错误,希望能得到解决。

答案 1 :(得分:10)

只需关闭离线模式即可。这对我有用。

答案 2 :(得分:6)

在我的情况下,重启Android Studio解决了我的问题

答案 3 :(得分:0)

尝试

  • 构建 - >清洁项目

答案 4 :(得分:0)

进入一个类似的问题,但对我来说这是因为我忘了初始化我的git子模块导致一个android模块没有在那里抛出同样的错误...

答案 5 :(得分:0)

这个错误也发生在我身上。事实证明它与kyhule的原因相同,不同模块gradle中的buildTypes必须完全匹配。

只是想通过命令行./gradlew build从终端构建gradle来更容易找到错误的位置。它将提供您可以遵循的更有用的信息来解决您的问题。

答案 6 :(得分:0)

当我遇到类似错误时,我发现我需要使用更新版本的Android Studio。当我使用Android Studio 3 Canary 2时出现此错误,但之后我使用了最新的测试版,这解决了我的问题。

答案 7 :(得分:0)

尝试归档 - >使高速缓存/重新启动无效

答案 8 :(得分:0)

对我来说,事件日志显示为:

2:18 PM Project setup started

2:18 PM Gradle sync failed: EventQueue.isDispatchThread()=false Toolkit.getEventQueue()=com.intellij.ide.IdeEventQueue@40306e17
                Current thread: Thread[ApplicationImpl pooled thread 3,4,Idea Thread Group] 1439896692
                SystemEventQueueThread: Thread[AWT-EventQueue-0,6,Idea Thread Group] 519777864 (2 s 913 ms)

2:18 PM Syncing only active variant
                You can disable this experimental feature from
                File → Settings → Experimental → Gradle → Only sync the active variant

我尝试了所有操作,但可以肯定的是,我只需要按照说的去做,然后取消选中“仅同步活动的变体”复选框。不确定如何首先检查它。

答案 9 :(得分:0)

我按照给定的步骤解决了这个问题:-

  1. 转到SDK Manager(Ctrl + Shift + A,然后键入SDK Manager)。
  2. 转到SDK工具
  3. 取消选择或卸载除Android支持存储库和Android SDK平台工具以外的所有SDK工具
  4. 再试一次以同步项目。