简体   繁体   English

Gradle在Android Studio中构建时出现错误

[英]Gradle is build with errors in android studio

I am using android studio.This is the error suddenly I got when building gradle. 我正在使用android studio。这是构建gradle时突然出现的错误。 Earlier it was working correctly. 之前它工作正常。 I close the android studio and re-build the gradle. 我关闭了android studio并重新构建了gradle。 But doesn't fix the error. 但是并不能解决错误。 I clean and rebuild the gradle. 我清理并重建gradle。

Can you solve the problem. 您能解决问题吗?

Error:org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$FileCollectionSnapshotImpl cannot be cast to org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter$OutputFilesSnapshot

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) Gradle的依赖项缓存可能已损坏(这有时会在网络连接超时后发生。)重新下载依赖项并同步项目(需要网络)
  • The state of a Gradle build process (daemon) may be corrupt. Gradle构建过程(守护程序)的状态可能已损坏。 Stopping all Gradle daemons may solve this problem. 停止所有Gradle守护程序可以解决此问题。 Stop Gradle build processes (requires restart) 停止Gradle构建过程(需要重新启动)
  • 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. 您的项目可能使用的第三方插件与该项目中的其他插件或该项目要求的Gradle版本不兼容。
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes. 如果Gradle进程损坏,您也可以尝试关闭IDE,然后终止所有Java进程。

Following display my build.gradle information 以下显示我的build.gradle信息

classpath 'com.android.tools.build:gradle:1.5.0' pply plugin: 'com.android.application' compileSdkVersion 23 buildToolsVersion "23.0.2" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" classpath'com.android.tools.build:gradle:1.5.0'pply插件:'com.android.application'compileSdkVersion 23 buildToolsVersion“ 23.0.2” minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName“ 1.0”

Gradle may be not found. 找不到摇篮。 Try to change gradle version and update it with your gradle version like in project : 尝试更改gradle版本并像项目中那样使用您的gradle版本进行更新:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

and this one in module of gradle : 和gradle的模块中的这个:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.yourproject"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 14
        versionName '1.4'
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM