Gradle 3.0.0-beta1构建问题

时间:2017-08-10 06:30:36

标签: android android-studio android-gradle build.gradle gradlew

我刚刚将gradle版本更新为

classpath 'com.android.tools.build:gradle:3.0.0-beta1'

将android studio更新为3.0-beta1后,我的gradle-wrapper为:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip

问题是当我想要Gradle-sync项目时,我正面临这个奇怪的问题:

Error:Cause: java.lang.NullPointerException
at sun.nio.fs.UnixPath.normalizeAndCheck(UnixPath.java:77)
at sun.nio.fs.UnixPath.<init>(UnixPath.java:71)
at sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:281)
at java.nio.file.Paths.get(Paths.java:84)
at com.android.build.gradle.internal.scope.BuildOutput.getOutputPath(BuildOutput.java:222)
at com.android.build.gradle.internal.scope.BuildOutputs.lambda$load$2(BuildOutputs.java:243)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1376)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.android.build.gradle.internal.scope.BuildOutputs.load(BuildOutputs.java:245)
at com.android.build.gradle.internal.scope.BuildOutputs.load(BuildOutputs.java:184)
at com.android.build.gradle.internal.scope.BuildOutputs.load(BuildOutputs.java:140)
at com.android.build.gradle.internal.ide.BuildOutputsSupplier.lambda$get$1(BuildOutputsSupplier.java:55)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:397)
at com.android.build.gradle.internal.ide.BuildOutputsSupplier.get(BuildOutputsSupplier.java:50)
at com.android.build.gradle.internal.ide.BuildOutputsSupplier.get(BuildOutputsSupplier.java:35)
at com.android.build.gradle.internal.ide.AndroidArtifactImpl.getOutputs(AndroidArtifactImpl.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$ReflectionMethodInvoker.invoke(ProtocolToModelAdapter.java:592)
at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$AdaptingMethodInvoker.invoke(ProtocolToModelAdapter.java:397)
at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$PropertyCachingMethodInvoker.invoke(ProtocolToModelAdapter.java:625)
at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SafeMethodInvoker.invoke(ProtocolToModelAdapter.java:647)
at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$SupportedPropertyInvoker.invoke(ProtocolToModelAdapter.java:670)
at org.gradle.tooling.internal.adapter.ProtocolToModelAdapter$InvocationHandlerImpl.invoke(ProtocolToModelAdapter.java:356)
at com.sun.proxy.$Proxy204.getOutputs(Unknown Source)
at com.android.tools.idea.gradle.project.model.ide.android.IdeAndroidArtifactImpl.<init>(IdeAndroidArtifactImpl.java:57)
at com.android.tools.idea.gradle.project.model.ide.android.IdeVariantImpl.lambda$new$1(IdeVariantImpl.java:63)
at com.android.tools.idea.gradle.project.model.ide.android.ModelCache.lambda$computeIfAbsent$0(ModelCache.java:31)
at java.util.HashMap.computeIfAbsent(HashMap.java:1126)
at com.android.tools.idea.gradle.project.model.ide.android.ModelCache.computeIfAbsent(ModelCache.java:31)
at com.android.tools.idea.gradle.project.model.ide.android.IdeModel.copy(IdeModel.java:74)
at com.android.tools.idea.gradle.project.model.ide.android.IdeVariantImpl.<init>(IdeVariantImpl.java:62)
at com.android.tools.idea.gradle.project.model.ide.android.IdeAndroidProjectImpl.lambda$new$4(IdeAndroidProjectImpl.java:88)
at com.android.tools.idea.gradle.project.model.ide.android.ModelCache.lambda$computeIfAbsent$0(ModelCache.java:31)
at java.util.HashMap.computeIfAbsent(HashMap.java:1126)
at com.android.tools.idea.gradle.project.model.ide.android.ModelCache.computeIfAbsent(ModelCache.java:31)
at com.android.tools.idea.gradle.project.model.ide.android.IdeModel.copy(IdeModel.java:74)
at com.android.tools.idea.gradle.project.model.ide.android.IdeAndroidProjectImpl.<init>(IdeAndroidProjectImpl.java:87)
at com.android.tools.idea.gradle.project.model.ide.android.IdeAndroidProjectImpl.<init>(IdeAndroidProjectImpl.java:68)
at com.android.tools.idea.gradle.project.model.AndroidModuleModel.<init>(AndroidModuleModel.java:131)
at com.android.tools.idea.gradle.project.sync.idea.AndroidGradleProjectResolver.populateModuleContentRoots(AndroidGradleProjectResolver.java:214)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.populateModuleContentRoots(AbstractProjectResolverExtension.java:103)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:366)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$200(GradleProjectResolver.java:79)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:902)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:886)
at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:218)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:139)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:79)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo$0(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:45)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:66)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:139)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:125)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:388)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$5.run(ExternalSystemUtil.java:445)
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)

我检查过所有内容,看起来都很好,有人可以帮忙吗?

6 个答案:

答案 0 :(得分:13)

Build -> Clean project,然后是

Build -> Rebuild project

答案 1 :(得分:3)

根据官方 link,这是已知问题。

  

已知问题 :如果您有一个现有的Android Studio项目,那就是&#39; s   使用Android版插件3.0.0的alpha版本(例如3.0.0-alpha9),   迁移到Android插件时,您可能会收到以下错误   3.0.0-beta1和sync your project Gradle项目刷新失败。

     

解决方案 :选择构建&gt;解决此问题从菜单中清除项目   bar - 您需要为每个项目仅执行一次此操作。您   然后,您可以点击同步项目,将项目文件与Gradle同步   从菜单栏。

答案 2 :(得分:2)

尝试此选项:

  1. 保持Gradle Sync错误,并清理项目
  2. 重建项目
  3. 现在同步Gradle
  4. 注意: 我也做了

      

    无效并重新启动

    在尝试之前

    它帮助了我,希望它也能帮到你。

答案 3 :(得分:0)

3.0.0中存在一些已知错误,这个问题就是其中之一,实际上android studio正在为Linux操作系统集成Unix文件系统(Berkeley Fast File System)并且它处于测试阶段....请将你的工作室降级到2.3.3现在稳定版。

答案 4 :(得分:0)

我在更新 beta1 后遇到了同样的问题。 尝试在SDK Manager中将构建工具更新到最新版本 - &gt; SDK工具。然后将google maven添加到 root build.gradle ,如下所示:

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
}

这适用于我的情况

答案 5 :(得分:0)

我尝试在Linux Mint 18.1上升级到3.0.0-beta1时遇到了同样的问题。以上都没有帮助:既不干净 - &gt;重建 - &gt;同步,也无效和无效重新开始。但Sanat建议降级到2.3.3有助于