离线Maven回购中缺少Gradle插件

时间:2017-05-22 00:01:13

标签: android maven android-studio gradle android-gradle

我无法运行我的项目,因为当我尝试这样做时会出现错误消息: 离线Maven回购中缺少Gradle插件 当我看到细节时,这是向我展示的:

java.lang.IllegalStateException: Gradle plugin missing from the offline Maven repo
at com.android.tools.idea.gradle.plugin.AndroidPluginGeneration.getLatestKnownVersion(AndroidPluginGeneration.java:213)
at com.android.tools.idea.gradle.plugin.AndroidPluginGeneration$1.getLatestKnownVersion(AndroidPluginGeneration.java:68)
at com.android.tools.idea.gradle.project.sync.setup.post.PluginVersionUpgrade.log(PluginVersionUpgrade.java:64)
at com.android.tools.idea.gradle.project.sync.setup.post.PluginVersionUpgrade.checkAndPerformUpgrade(PluginVersionUpgrade.java:51)
at com.android.tools.idea.gradle.project.sync.setup.post.PostSyncProjectSetup.setUpProject(PostSyncProjectSetup.java:163)
at com.android.tools.idea.gradle.util.Projects.lambda$populate$2(Projects.java:182)
at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2453)
at com.android.tools.idea.gradle.util.Projects.populate(Projects.java:168)
at com.android.tools.idea.gradle.util.Projects.populate(Projects.java:120)
at com.android.tools.idea.gradle.project.sync.idea.ProjectSetUpTask.lambda$populateProject$1(ProjectSetUpTask.java:120)
at com.intellij.ide.startup.impl.StartupManagerImpl.lambda$runWhenProjectIsInitialized$5(StartupManagerImpl.java:370)
at com.intellij.openapi.application.TransactionGuardImpl$6.run(TransactionGuardImpl.java:291)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:326)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:310)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:795)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:631)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
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)

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

你有没有更新到Android Studio 3.0 Canary 1?

如果是这样,我也遇到了同样的问题。他们将一些东西移到新的存储库中:https://maven.google.com

所以我必须在build.gradle文件中添加以下代码

repositories {
  maven {
   url "https://maven.google.com"
  }
}

此外,仍然在gradle中,我不得不实际更新以下依赖项:

dependencies {
  classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
}

最后,还需要更新gradle-wrapper:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip

希望它会有所帮助

答案 1 :(得分:0)

我通过删除文件夹" gradle"来解决这个问题。在Android Studio的根目录中,运行File - >在Android Studio中使缓存/重新启动无效,然后复制文件夹" gradle"从新下载的相同版本的Android Studio到Android Studio的根目录。然后重新启动Android Studio。

我并不是说这是解决这个问题的正确方法,但它对我有用 - Android Studio alphas和beta版不是稳定的版本。