1

我已經搜索了很多關於此問題的內容,但沒有任何內容適用於我。我剛剛更新過Android Studio 2.2的第三個預覽,我得到以下錯誤:Android Studio:更新後「Gradle項目刷新失敗」

Gradle'myApp' project refresh failed 

Error:Cause: java.lang.NullPointerException 
    at java.util.Objects.requireNonNull(Objects.java:203) 
    at java.util.Arrays$ArrayList.<init>(Arrays.java:3813) 
    at java.util.Arrays.asList(Arrays.java:3800) 
    at com.intellij.openapi.util.io.FileUtilRt.doCreateTempFile(FileUtilRt.java:399) 
    at com.intellij.openapi.util.io.FileUtilRt.createTempFile(FileUtilRt.java:361) 
    at com.intellij.openapi.util.io.FileUtilRt.createTempFile(FileUtilRt.java:341) 
    at com.intellij.openapi.util.io.FileUtilRt.createTempFile(FileUtilRt.java:334) 
    at com.intellij.openapi.util.io.FileUtil.createTempFile(FileUtil.java:1479) 
    at com.android.tools.idea.gradle.util.GradleUtil.addInitScriptCommandLineOption(GradleUtil.java:964) 
    at com.android.tools.idea.gradle.util.GradleUtil.addLocalMavenRepoInitScriptCommandLineOption(GradleUtil.java:957) 
    at com.android.tools.idea.gradle.util.GradleUtil.addLocalMavenRepoInitScriptCommandLineOption(GradleUtil.java:923) 
    at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getExtraCommandLineArgs(AndroidGradleProjectResolver.java:339) 
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:174) 
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:72) 
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:757) 
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:741) 
    at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:238) 
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:111) 
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:72) 
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41) 
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(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:49) 
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51) 
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138) 
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124) 
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:419) 
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:500) 
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563) 
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142) 
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446) 
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54) 
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126) 
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:369) 
    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) 

我檢查我的gradle這個設置,清理和重建我的項目,即使刪除了.gradle文件。

這是我的build.gradle(模塊的應用程序):

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion '24.0.0' 

    defaultConfig { 
     applicationId "fogames.thecolourapp" 
     minSdkVersion 12 
     targetSdkVersion 24 
     versionCode 4 
     versionName "1.0.3" 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.0.0' 
    compile 'com.android.support:design:24.0.0' 
    compile 'com.google.android.gms:play-services-appindexing:9.2.1' 
    compile 'com.android.support:support-v4:24.0.0' 
} 

編輯:我已經能夠建造和安裝一次APK,但大部分時間我得到這個錯誤或「未知錯誤」 。

EDIT2:在搖籃構建我得到:

Error:Failed to complete Gradle execution. Cause: unknown. 

在搖籃控制檯我得到:

Executing tasks: [:app:generateDebugSources, :app:compileDebugSources] 

回答

0

轉到File - Invalidate Cache and Restart。除非您在更新後更改了build.gradle中的內容,否則此後應該很好。如果你這樣做,請回復並檢查是否是由於問題引起的。

+0

它沒有工作。 –

+0

兩年後,我從Android Studio 2.1更新到2.2後,進入相同的問題。任何想法可能是什麼問題? – Rafal

+0

AS 2.2在項目結構上有變化。這個問題可能完全不同。建議重新導入/轉換。 – AndroidMechanic

相關問題