Skip to main content

org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.

Error:Cause: org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection Possible causes for this unexpected error include:
  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Solutions:
Upgrade your gradle build tools to the latest version.
One easy way to do this is to add the latest version of the build tools as a dependency in your build.gradle file, for example:
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0-beta1'
}
You can then run gradle tasks and gradle will download everything you need.
After Android Studio 2.2 stable released on Sep 19 2016 , the latest version of the build tools is 2.2.0 . So you can fix it by :
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
}
As Android Studio 2.4 stable is not ready to release yet (May 4 2017), the latest stable version of build tools is 2.3.1 .
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'
}
If you update this build tools version to 2.3.* , you should also update gradle wrapper version to 3.3 in /yourProjectRoot/gradle/wrapper/gradle-wrapper.properties file. (i know it is not matching question Gradle build failing after update to 3.0, but i strongly suggest you to use latest build tool as google recommended)
BTW: version 2.3.1 of build tool is only exist on jCenter, not MavenCentral, so if you run into error below when run gradlew command line in terminal
Could not find com.android.tools.build:gradle:2.3.1.
 Searched in the following locations:
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.pom
     https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.jar
just replace mavenCentral() with jcenter() like
 repositories {
    jcenter()
    //mavenCentral()
}

Comments

  1. After hours of hours I found this unique solution, thanks.
    Somebody (not me) called android studio as ASS - android stupid studio.

    ReplyDelete

Post a Comment

Popular posts from this blog

Error:Execution failed for task ':app:processDebugGoogleServices'. > Missing api_key/current_key object

First in your JSON file Replace "api_key" : [] with "api_key" : [{ "current_key" : "" }] Then the gradle build will be successful but when you run your application you may get errors like the following.. Error : Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug' . > com . android . build . api . transform . TransformException : com . android . builder . packaging . DuplicateFileException : Duplicate files copied in APK META - INF / LICENSE File1 : C : \Users\bucky\.gradle\caches\modules - 2 \files - 2.1 \com . fasterxml . jackson . core\jackson - core\2 . 2.2 \d 20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b \jackson - core - 2.2 . 2.jar File2 : C : \Users\bucky\.gradle\caches\modules - 2 \files - 2.1 \com . fasterxml . jackson . core\jackson - databind\2 . 2.2 \3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson - databind - 2.2 . 2.jar File3 : C : \Users\bucky\.gradle\caches\mod

How to get mobilesdk_app_id parameter in google-services.json

The google-services.json file is generally placed in the app/ directory,  but as of version 2.0.0-alpha3 of the plugin support was added for build types , which would make the following directory structure valid: app / src / main / google - services . json dogfood / google - services . json mytype1 / google - services . json mobilesdk_app_id : At the following page:  https://developers.google.com/mobile/add?platform=android&cntapi=signin&cntapp=Default%20Demo%20App&cntpkg=com.google.samples.quickstart.signin&cnturl=https:%2F%2Fdevelopers.google.com%2Fidentity%2Fsign-in%2Fandroid%2Fstart%3Fconfigured%3Dtrue&cntlbl=Continue%20with%20Try%20Sign-In You can create a new project and add services to it. This website will automatically generate a google-services.json file for your new project.

Access can be package - Private, Protected and Public ( Differences )

Java has four access modifier namely  private ,  protected  and  public . package level access is  default access  level provided by Java  if no access modifier is specified. These access modifiers are used to restrict accessibility of a class, method or variable on which it applies. We will start from private access modifier which is most restrictive access modifier and then go towards public which is least restrictive access modifier, along the way we will see some best practices while using access modifier in Java and some examples of using  private  and  protected  keywords. private keyword in Java private  keyword or modifier in java can be applied to member field, method or nested class in Java. you can not use the  private  modifier on top level class.  private  variables, methods, and class are only accessible on the class on which they are declared.  private  is the highest form of Encapsulation Java API provides and should be used as much as possible. It's best c