Android Gradle - 断言错误

时间:2014-12-08 22:22:30

标签: android gradle

当我尝试进行Gradle Sync时,出现以下错误:

  

21:24:11 AssertionError:   com.android.tools.idea.gradle.project.AndroidGradleProjectComponent@8e8dc05   22:13:53 AssertionError:null

当我详细查看错误时,我得到堆栈跟踪

  

null java.lang.AssertionError at   com.android.tools.idea.gradle.project.PreSyncChecks.attemptToUpdateGradleVersionInWrapper(PreSyncChecks.java:174)     在   com.android.tools.idea.gradle.project.PreSyncChecks.ensureCorrectGradleSettings(PreSyncChecks.java:72)     在   com.android.tools.idea.gradle.project.PreSyncChecks.canSync(PreSyncChecks.java:53)     在   com.android.tools.idea.gradle.project.GradleProjectImporter.doImport(GradleProjectImporter.java:430)     在   com.android.tools.idea.gradle.project.GradleProjectImporter.doRequestSync(GradleProjectImporter.java:219)     在   com.android.tools.idea.gradle.project.GradleProjectImporter.access $ 000(GradleProjectImporter.java:77)     在   com.android.tools.idea.gradle.project.GradleProjectImporter $ 2.run(GradleProjectImporter.java:184)     在   com.intellij.ui.AppUIUtil.invokeLaterIfProjectAlive(AppUIUtil.java:77)     在   com.android.tools.idea.gradle.project.GradleProjectImporter.requestProjectSync(GradleProjectImporter.java:191)     在   com.android.tools.idea.gradle.project.GradleProjectImporter.requestProjectSync(GradleProjectImporter.java:166)     在   com.android.tools.idea.gradle.actions.SyncProjectAction.actionPerformed(SyncProjectAction.java:43)     在   com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:164)     在   com.intellij.openapi.actionSystem.impl.ActionButton.actionPerformed(ActionButton.java:170)     在   com.intellij.openapi.actionSystem.impl.ActionButton.performAction(ActionButton.java:133)     在   com.intellij.openapi.actionSystem.impl.ActionButton.processMouseEvent(ActionButton.java:313)     在java.awt.Component.processEvent(Component.java:6179)at   java.awt.Container.processEvent(Container.java:2084)at   java.awt.Component.dispatchEventImpl(Component.java:4776)at   java.awt.Container.dispatchEventImpl(Container.java:2142)at   java.awt.Component.dispatchEvent(Component.java:4604)at   java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)     在   java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4209)     在java.awt.Container.dispatchEventImpl(Container.java:2128)at   java.awt.Window.dispatchEventImpl(Window.java:2492)at   java.awt.Component.dispatchEvent(Component.java:4604)at   java.awt.EventQueue.dispatchEventImpl(EventQueue.java:717)at at   java.awt.EventQueue.access $ 400(EventQueue.java:82)at   java.awt.EventQueue $ 2.run(EventQueue.java:676)at   java.awt.EventQueue $ 2.run(EventQueue.java:674)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.AccessControlContext $ 1.doIntersectionPrivilege(AccessControlContext.java:86)     在   java.security.AccessControlContext $ 1.doIntersectionPrivilege(AccessControlContext.java:97)     在java.awt.EventQueue $ 3.run(EventQueue.java:690)at   java.awt.EventQueue $ 3.run(EventQueue.java:688)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.AccessControlContext $ 1.doIntersectionPrivilege(AccessControlContext.java:86)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:687)at   com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)     在   com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:520)     在   com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)     在   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)     在java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

知道如何解决这个问题吗?

3 个答案:

答案 0 :(得分:3)

更改

classpath 'com.android.tools.build:gradle:1.0.0'

classpath 'com.android.tools.build:gradle:0.14.4'

在build.gradle文件中

答案 1 :(得分:2)

如果您使用的IntelliJ和Android Gradle插件大于0.14,则可能会出现此错误。我提出了一个错误:

https://youtrack.jetbrains.com/issue/IDEA-134118

明星问题,投票,他们可能会仔细看看:)。

答案 2 :(得分:0)

您的build.gradle中可能设置了错误的gradle版本。

尝试在您的gradle依赖项中更改gradle构建版本,如下所示

dependencies {
     classpath 'com.android.tools.build:gradle:0.13.+'
}