ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Unable to find method 'org.gradle.api.tasks.TaskInputs.file

2020-06-15 16:07:00  阅读:341  来源: 互联网

标签:tasks implementation greendao gradle Unable 3.2 org android


在配置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'

}

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

标签:tasks,implementation,greendao,gradle,Unable,3.2,org,android
来源: https://www.cnblogs.com/lixiangyang521/p/13131405.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有