【发布时间】:2021-10-21 19:44:53
【问题描述】:
当 Android Studio gradle 尝试构建我的应用程序时,我遇到了以下异常。
行:3
评估项目“:app”时出现问题。 没有方法签名: build_9zxr20k2zkn73ctdrehcrmd74.android() 适用于参数类型: (build_9zxr20k2zkn73ctdrehcrmd74$_run_closure1) 值: [build_9zxr20k2zkn73ctdrehcrmd74$_run_closure1@2ecd80]
org.gradle.api.GradleScriptException:评估时出现问题 项目':应用程序'。引起:groovy.lang.MissingMethodException:否 方法的签名: build_9zxr20k2zkn73ctdrehcrmd74.android() 是 适用于参数类型: (build_9zxr20k2zkn73ctdrehcrmd74$_run_closure1) 值: [build_9zxr20k2zkn73ctdrehcrmd74$_run_closure1@2ecd80] 在 build_9zxr20k2zkn73ctdrehcrmd74.run
这里是 build.gradle 文件
build.gradle(项目)
apply plugin: 'com.android.application'
android {
compileSdkVersion 31
defaultConfig {
applicationId "net.estebanrodriguez.anecdotals"
minSdkVersion 22
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath true
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//material design components
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.core:core:1.7.0-rc01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.media:media:1.4.3'
implementation 'androidx.fragment:fragment:1.4.0-alpha10'
implementation 'androidx.appcompat:appcompat:1.4.0-beta01'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
//Firebase
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-firestore:23.0.4'
//Android Architecture Components
def room_version = '2.0.0-beta01'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
def lifecycle_version = '2.0.0-beta01'
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation 'androidx.multidex:multidex:2.0.1'
//Timber
implementation 'com.jakewharton.timber:timber:4.7.1'
//Dagger 2
implementation 'com.google.dagger:dagger-android:2.35.1'
implementation 'com.google.dagger:dagger-android-support:2.20'
// if you use the support libraries
annotationProcessor 'com.google.auto.value:auto-value:1.5.2'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.20'
annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
//RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.2.6'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version)
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(模块)
apply plugin: 'com.android.application'
android {
compileSdkVersion 31
defaultConfig {
applicationId "net.estebanrodriguez.anecdotals"
minSdkVersion 22
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath true
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//material design components
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.core:core:1.7.0-rc01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.media:media:1.4.3'
implementation 'androidx.fragment:fragment:1.4.0-alpha10'
implementation 'androidx.appcompat:appcompat:1.4.0-beta01'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
//Firebase
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-firestore:23.0.4'
//Android Architecture Components
def room_version = '2.0.0-beta01'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
def lifecycle_version = '2.0.0-beta01'
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation 'androidx.multidex:multidex:2.0.1'
//Timber
implementation 'com.jakewharton.timber:timber:4.7.1'
//Dagger 2
implementation 'com.google.dagger:dagger-android:2.35.1'
implementation 'com.google.dagger:dagger-android-support:2.20'
// if you use the support libraries
annotationProcessor 'com.google.auto.value:auto-value:1.5.2'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.20'
annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
//RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.2.6'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version)
implementation 'io.reactivex.rxjava2:rxjava:2.2.6'
}
apply plugin: 'com.google.gms.google-services'
【问题讨论】: