我从github克隆了源代码,并将 Android Studio更新为3.5 ,升级为5.4.1 ,
它显示错误Gradle DSL method not found: 'destination()'
,我尝试通过在file
文件夹中的quality.gradle
上添加.../config/quality/.
方法来查找stackoverflow link中错误的答案。
但是它显示新的错误消息
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.)
我无法解决。请告诉我。
此 quality.gragle 文件
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:6.5'
}
def qualityConfigDir = "$project.rootDir/config/quality";
def reportsDir = "$project.buildDir/reports"
check.dependsOn 'checkstyle', 'findbugs', 'pmd'
task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code style checks') {
configFile file("$qualityConfigDir/checkstyle/checkstyle-config.xml")
source 'src'
include '**/*.java'
exclude '**/model/**'
exclude '**/AppLogger.java'
reports {
xml.enabled = true
xml {
destination file("$reportsDir/checkstyle/checkstyle.xml")
}
}
classpath = files()
}
task findbugs(type: FindBugs,
group: 'Verification',
description: 'Inspect java bytecode for bugs',
dependsOn: ['compileDebugSources', 'compileReleaseSources']) {
ignoreFailures = false
effort = "max"
reportLevel = "high"
excludeFilter = new File("$qualityConfigDir/findbugs/android-exclude-filter.xml")
classes = files("$project.rootDir/app/build/intermediates/classes")
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = true
html.enabled = false
xml {
destination file("$reportsDir/findbugs/findbugs.xml")
}
html {
destination file("$reportsDir/findbugs/findbugs.html")
}
}
classpath = files()
}
task pmd(type: Pmd, group: 'Verification', description: 'Inspect sourcecode for bugs') {
ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml")
ignoreFailures = false
ruleSets = []
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/model/**'
reports {
xml.enabled = true
html.enabled = true
xml {
destination file("$reportsDir/pmd/pmd.xml")
}
html {
destination file("$reportsDir/pmd/pmd.html")
}
}
}
build.gradle文件(项目)
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Define versions in a single place
ext {
// Sdk and tools
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
// App dependencies
supportLibraryVersion = '26.1.0'
gsonVersion = '2.8.0'
calligraphyVersion = '2.2.0'
glideVersion = '3.7.0'
rx2FastAndroidNetworking = '1.0.1'
dagger2Version = '2.8'
rxjava2Version = '2.0.6'
rxandroidVersion = '2.0.1'
butterKnifeVersion = '8.6.0'
greenDaoVersion = '3.2.0'
placeholderviewVersion = '0.6.1'
debugDBVersion = '1.0.3'
timberVersion = '4.5.1'
//Test dependencies
junitVersion = '4.12'
espressoVersion = '2.2.2'
mockitoVersion = '2.7.1'
}
build.gradle文件(应用程序)
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply from: '../config/quality/quality.gradle'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.mindorks.framework.mvp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
buildConfigField("String", "BASE_URL", "\"http://www.mocky.io/v2\"")
buildConfigField("String", "API_KEY", "\"ABCXYZ123TEST\"")
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "BASE_URL", "\"http://www.mocky.io/v2\"")
buildConfigField("String", "API_KEY", "\"ABCXYZ123TEST\"")
}
}
}
greendao {
schemaVersion 1
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// android support libraries
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
implementation "com.android.support:animated-vector-drawable:$rootProject.supportLibraryVersion"
// font
implementation "uk.co.chrisjenx:calligraphy:$rootProject.calligraphyVersion"
// network
implementation "com.amitshekhar.android:rx2-android-networking:$rootProject.rx2FastAndroidNetworking"
// image
implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
// parser
implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
// database
implementation "org.greenrobot:greendao:$rootProject.greenDaoVersion"
// debug database
debugImplementation "com.amitshekhar.android:debug-db:$rootProject.debugDBVersion"
// dependency injection
implementation "com.google.dagger:dagger:$rootProject.dagger2Version"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2Version"
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'javax.inject:javax.inject:1'
// reactive
implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxjava2Version"
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroidVersion"
// code generator for view
implementation "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"
// swipe view
implementation "com.mindorks:placeholderview:$rootProject.placeholderviewVersion"
// logger
implementation "com.jakewharton.timber:timber:$rootProject.timberVersion"
// dependencies for local unit tests
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
testAnnotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2Version"
// UI Testing
androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$rootProject.espressoVersion"
androidTestImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2Version"
}
configurations.all {
resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion"
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip