zoukankan      html  css  js  c++  java
  • Unable to find method 'org.gradle.api.tasks.TaskInputs.file

    在配置greenDao项目的时候,经常会遇到这样的问题,全部的提示如下

    Unable to find method ‘org.gradle.api.tasks.TaskInputs.file(Ljava/lang/Object;)Lorg/gradle/api/tasks/TaskInputs;’.
    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.
    

     导致这个问题的原因是gradle版本的问题,在我这里出现这个问题时的配置如下

    android studio 4.0.0
    gradle:6.1.1
    gradle Plugin:3.2.0
    greenDao: 3.2.0

    修改之后可以正常使用的配置如下

    android studio 4.0.0
    gradle:6.1.1
    gradle Plugin:3.3.0
    greenDao: 3.2.0

    正确配置,外面的build.gradle的buildscript中配置gradle

    buildscript {
        repositories {
            google()
            jcenter()
            maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        }
        dependencies {
            classpath "com.android.tools.build:gradle:4.0.0-rc01"
            // 使用butterknife需要实现以下方法
            classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
            classpath 'org.greenrobot:greendao-gradle-plugin:3.3.0'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    

     在里面的build.gradle中配置

    apply plugin: 'com.android.application'
    apply plugin: 'org.greenrobot.greendao' // 添加应用依赖插件
    
    android {
        compileSdkVersion 29
    
        defaultConfig {
            applicationId "com.example.easygreendao"
            minSdkVersion 16
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    
    // 配置GreenDao基本参数
        greendao {
            schemaVersion 1 //当前数据库版本
        }
    
    }
    
    dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    
    
        //greendao
        implementation 'org.greenrobot:greendao:3.2.0' // add library
        implementation 'org.greenrobot:greendao-generator:3.2.0' // add library
        implementation 'com.github.yuweiguocn:GreenDaoUpgradeHelper:v2.1.0'
    
    }
    

     经过上面配置,可以正常编译运行。

  • 相关阅读:
    brew
    hbase
    YARN常见问题以及解决方案
    mybatis中foreach collection三种用法
    mysql按分隔符输出多行
    mysql DATETIME
    iis 之给网站添加MIME映射
    VS2019专业版和企业版激活密钥
    ViewData对于从后台传list到前台的使用
    找出每组数据中不同distinct
  • 原文地址:https://www.cnblogs.com/lixiangyang521/p/13131405.html
Copyright © 2011-2022 走看看