当前位置: 首页 > 知识库问答 >
问题:

Android Gradle构建错误:由:groovy.lang.MissingMachodException引起:方法没有签名

张逸清
2023-03-14

当Android studio gradle尝试构建我的应用程序时,我遇到了以下例外情况。

行:3

评估项目“:app”时出现问题。方法无签名:build\u 9zxr20k2zkn73ctdrehcrmd74。android()适用于参数类型:(build\u 9zxr20k2zkn73ctdrehcrmd74$\u run\u closure1)值:[build\u 9zxr20k2zkn73ctdrehcrmd74$\u run_closure1@2ecd80]

组织。格拉德尔。应用程序编程接口。GradleScriptException:评估项目“:app”时出现问题。原因:groovy。lang.MissingMethodException:没有方法的签名:build\u 9zxr20k2zkn73ctdrehcrmd74。android()适用于参数类型:(build\u 9zxr20k2zkn73ctdrehcrmd74$\u run\u closure1)值:[build\u 9zxr20k2zkn73ctdrehcrmd74$\u run_closure1@2ecd80]在build\u 9zxr20k2zkn73ctdrehcrmd74。跑

以下是构建。gradle文件

建筑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'

建筑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'

共有1个答案

钱毅
2023-03-14

可能会删除项目目录中以开头的目录 像<代码>。渐变和。想法可以奏效。同时删除app目录中的build文件夹。

 类似资料: