Intellij Gradle同步失败

时间:2019-09-13 01:09:39

标签: android gradle intellij-idea android-gradle-plugin

我想使用Intellij代替Android Studio来制作android应用。问题是当我创建一个新的project时出现错误

  

“ Gradle项目同步失败。基本功能(例如,编辑,调试)将无法正常工作。”   错误:无法解析':app @ debug / compileClasspath'的依赖关系:找不到与com.android.support:appcompat-v7:29.+匹配的任何版本。

致命错误 异常报告

  

java.lang.AssertionError:已处理:Module:'app'       在com.intellij.openapi.components.impl.ComponentManagerImpl.lambda $ throwAlreadyDisposed $ 1(ComponentManagerImpl.java:245)       在com.intellij.openapi.application.ReadAction.lambda $ run $ 1(ReadAction.java:53)       在com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:974)       在com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)       在com.intellij.openapi.application.ReadAction.run(ReadAction.java:53)       在com.intellij.openapi.components.impl.ComponentManagerImpl.throwAlreadyDisposed(ComponentManagerImpl.java:243)       在com.intellij.openapi.components.impl.ComponentManagerImpl.getPicoContainer(ComponentManagerImpl.java:236)       在com.intellij.openapi.components.impl.ComponentManagerImpl.getComponent(ComponentManagerImpl.java:146)       在com.intellij.facet.FacetManager.getInstance(FacetManager.java:31)       在com.android.tools.idea.gradle.project.facet.gradle.GradleFacet.getInstance(GradleFacet.java:57)       在com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile(GradleUtil.java:343)       在com.android.tools.idea.gradle.project.sync.issues.SyncIssuesReporter.report(SyncIssuesReporter.java:89)       在com.android.tools.idea.gradle.project.sync.issues.SyncIssuesReporter.report(SyncIssuesReporter.java:66)       在com.android.tools.idea.gradle.project.sync.idea.data.service.SyncIssueDataService.importData(SyncIssueDataService.java:40)       在com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.doImportData(ProjectDataManagerImpl.java:298)       在com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:165)       在com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:251)       在com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:258)       在org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder $ 1.lambda $ onSuccess $ 1(GradleProjectImportBuilder.java:144)       在org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder $ 1.onSuccess(GradleProjectImportBuilder.java:154)       在com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback.onSuccess(ExternalProjectRefreshCallback.java:40)       在com.intellij.openapi.externalSystem.util.ExternalSystemUtil $ 3.executeImpl(ExternalSystemUtil.java:574)       在com.intellij.openapi.externalSystem.util.ExternalSystemUtil $ 3.lambda $ execute $ 0(ExternalSystemUtil.java:399)       在com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:146)       在com.intellij.openapi.externalSystem.util.ExternalSystemUtil $ 3.execute(ExternalSystemUtil.java:399)       在com.intellij.openapi.externalSystem.util.ExternalSystemUtil $ 5.run(ExternalSystemUtil.java:664)       在com.intellij.openapi.progress.impl.CoreProgressManager $ TaskRunnable.run(CoreProgressManager.java:731)       在com.intellij.openapi.progress.impl.CoreProgressManager.lambda $ runProcess $ 2(CoreProgressManager.java:164)       在com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:586)       在com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)       在com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:86)       在com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)       在com.intellij.openapi.progress.impl.CoreProgressManager $ 4.run(CoreProgressManager.java:403)       在com.intellij.openapi.application.impl.ApplicationImpl $ 1.run(ApplicationImpl.java:311)       在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)       在java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)       在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)       在java.lang.Thread.run(Thread.java:748)

我已经在Google上浏览了一段时间,但是我没有找到解决方案,我尝试了其他解决方案来解决其他类似问题,但是仍然没有解决。

1 个答案:

答案 0 :(得分:1)

请将appCompat版本更改为:

com.android.support:appcompat-v7:28.0.0

相反

com.android.support:appcompat-v7:29.+

自从发布Android 9.0(API级别28)以来,有一个名为AndroidX的支持库新版本,版本29不再包含appCompat。 您也可以迁移到AndroidX(详细信息:https://developer.android.com/jetpack/androidx/releases/appcompat

dependencies {
def appcompat_version = "1.1.0"

implementation "androidx.appcompat:appcompat:$appcompat_version"
// For loading and tinting drawables on older versions of the platform
implementation "androidx.appcompat:appcompat-resources:$appcompat_version"

}