Gradle fails to sync due to @NotNull parameter 'aFileName' being null

After importing a project into Android Studio 1.3.0, gradle starts buiding the project and throws the error

00:47:21 Gradle sync started
00:47:25 Gradle sync failed: Argument for @NotNull parameter 'aFileName' of com/intellij/openapi/util/io/FileUtil.toSystemIndependentName must not be null
00:47:25 Gradle sync completed
00:47:26 IllegalArgumentException: Failed to set up Android modules in project 'Lab3a_IntentsLab': Argument for @NotNull parameter 'aFileName' of com/intellij/openapi/util/io/FileUtil.toSystemIndependentName must not be null

I don't know if it is because i imported it wrong or if it is some other problem. This is the exception trace.

Failed to set up Android modules in project 'Lab3a_IntentsLab': Argument for @NotNull parameter 'aFileName' of com/intellij/openapi/util/io/FileUtil.toSystemIndependentName must not be null
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'aFileName' of com/intellij/openapi/util/io/FileUtil.toSystemIndependentName must not be null
at com.intellij.openapi.util.io.FileUtil.toSystemIndependentName(FileUtil.java)
at org.jetbrains.android.sdk.AndroidSdkUtils.getPlatformDir(AndroidSdkUtils.java:216)
at org.jetbrains.android.sdk.AndroidSdkUtils.getPlatformAndAddOnJars(AndroidSdkUtils.java:120)
at org.jetbrains.android.sdk.AndroidSdkUtils.getLibraryRootsForTarget(AndroidSdkUtils.java:154)
at org.jetbrains.android.sdk.AndroidSdkUtils.setUpSdk(AndroidSdkUtils.java:402)
at org.jetbrains.android.sdk.AndroidSdkUtils.createNewAndroidPlatform(AndroidSdkUtils.java:352)
at org.jetbrains.android.sdk.AndroidSdkUtils.createNewAndroidPlatform(AndroidSdkUtils.java:334)
at org.jetbrains.android.sdk.AndroidSdkUtils.createNewAndroidPlatform(AndroidSdkUtils.java:325)
at org.jetbrains.android.sdk.AndroidSdkUtils.tryToCreateAndroidSdk(AndroidSdkUtils.java:610)
at com.android.tools.idea.gradle.customizer.android.AndroidSdkModuleCustomizer.customizeModule(AndroidSdkModuleCustomizer.java:76)
at com.android.tools.idea.gradle.customizer.android.AndroidSdkModuleCustomizer.customizeModule(AndroidSdkModuleCustomizer.java:41)
at com.android.tools.idea.gradle.service.AndroidProjectDataService.customizeModule(AndroidProjectDataService.java:330)
at com.android.tools.idea.gradle.service.AndroidProjectDataService.access$100(AndroidProjectDataService.java:88)
at com.android.tools.idea.gradle.service.AndroidProjectDataService$1.run(AndroidProjectDataService.java:159)
at com.intellij.openapi.command.WriteCommandAction$Simple.run(WriteCommandAction.java:166)
at com.intellij.openapi.application.RunResult.run(RunResult.java:38)
at com.intellij.openapi.command.WriteCommandAction$2$1.run(WriteCommandAction.java:114)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:931)
at com.intellij.openapi.command.WriteCommandAction$2.run(WriteCommandAction.java:111)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99)
at com.intellij.openapi.command.WriteCommandAction.performWriteCommandAction(WriteCommandAction.java:108)
at com.intellij.openapi.command.WriteCommandAction.execute(WriteCommandAction.java:80)
at com.android.tools.idea.gradle.service.AndroidProjectDataService.doImport(AndroidProjectDataService.java:136)
at com.android.tools.idea.gradle.service.AndroidProjectDataService.importData(AndroidProjectDataService.java:122)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:132)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:102)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:141)
at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager.importData(ProjectDataManager.java:148)
at com.android.tools.idea.gradle.util.Projects$1$1$1.run(Projects.java:128)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:328)
at com.android.tools.idea.gradle.util.Projects$1$1.run(Projects.java:124)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:931)
at com.android.tools.idea.gradle.util.Projects$1.run(Projects.java:120)
at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2369)
at com.android.tools.idea.gradle.util.Projects.populate(Projects.java:113)
at com.android.tools.idea.gradle.project.ProjectSetUpTask$2.run(ProjectSetUpTask.java:113)
at com.intellij.ide.startup.impl.StartupManagerImpl$7.run(StartupManagerImpl.java:369)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:706)
at java.awt.EventQueue$3.run(EventQueue.java:704)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:734)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:569)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

I wanto to know what this means and how to solve it.

The top level build.gradle

// Top-level build file where you can add configuration options common to    all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0+'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

And the gradle.build of the module itself

apply plugin: 'com.android.application'

android {
    compileSdkVersion 18
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "course.labs.intentslab"
        minSdkVersion 14
        targetSdkVersion 19

        testApplicationId "course.labs.intentslab.tests"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

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

dependencies {
    androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1+'
}

Answers


I encountered the same error. Just invalidate cache and restart it, it will work


I deleted the sdk platform of compile sdk version and redownloaded it in sdk manager.That solved the problem.Or like the asker said, changing the compileSdkVersion is another way.


Need Your Help

Laravel Homestead access

php laravel ssh laravel-5 homestead

Recently I've discovered Laravel Homestead and thought I'd give it a try. But as of now, every guide/tutorial I found uses ssh with it, making you bound to use a terminal window.