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'
    
    }
    

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

  • 相关阅读:
    [后缀数组] Luogu P5028 Annihilate
    [后缀数组] Luogu P3809 后缀排序
    [差分][线段树] Luogu P4243 等差数列
    [线段树] Luogu P4314 COU监控
    [二分][dp凸优化] Luogu P4383 林克卡特树lct
    [树上差分][dfs] Luogu P4652 One-Way Streets
    [dfs][思维] Luogu P3208 矩阵
    [dfs][二进制状压] Luogu P4906 小奔关闹钟
    [容斥] Luogu P5339 唱、跳、rap和篮球
    [dfs][模拟网络流] Luogu P4189 星际旅行
  • 原文地址:https://www.cnblogs.com/lixiangyang521/p/13131405.html
Copyright © 2011-2022 走看看