Android Studio 错误 - groovy.lang.MissingMethodException:没有方法签名:build_8sqj**q9.android() 适用于参数类型:***

Pan*_*waj 18 java gradle android-studio

我在 android studio 中准备了一个 android 应用程序,然后我将整个代码从一个系统手动复制到另一个系统。但之后,出现这个错误。下面是我的 gradle 文件和屏幕截图。(不确定为什么 android studio 中没有显示 manisfest 文件,这可能相关)请不要标记副本,因为我已经尝试了 stackoverflow 中的许多解决方案。这些是相同的错误,但似乎有不同的原因。

模块:应用程序


    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    
    android {
        compileSdkVersion 30
        buildToolsVersion '30.0.2'
        defaultConfig {
            applicationId "dhritiapps.tulsiramayan"
            minSdkVersion 23
            targetSdkVersion 30
            versionCode 23
            versionName 5.0
            multiDexEnabled true
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            compileOptions {
                sourceCompatibility 1.8
                targetCompatibility 1.8
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.navigation:navigation-fragment:2.2.1'
        implementation 'androidx.navigation:navigation-ui:2.2.1'
        implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
        implementation 'com.google.firebase:firebase-auth:20.0.1'
        implementation 'com.google.firebase:firebase-database:19.5.1'
        androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        implementation 'androidx.appcompat:appcompat:1.0.0'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.firebase:firebase-client-android:2.5.2'
        implementation 'com.google.android.gms:play-services-auth:18.1.0'
        implementation 'com.google.gms:google-services:4.3.4'
        implementation 'link.fls:swipestack:0.3.0'
        implementation 'com.airbnb.android:lottie:3.5.0'
        implementation 'com.github.bumptech.glide:glide:4.11.0'
        implementation platform('com.google.firebase:firebase-bom:26.2.0')
        implementation 'com.google.firebase:firebase-auth'
        implementation 'com.google.android.gms:play-services-auth:19.0.0'
        implementation 'me.priyesh:chroma:1.0.2'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
        implementation 'com.squareup.picasso:picasso:2.5.2'
        testImplementation 'junit:junit:4.13'
        testImplementation 'org.codehaus.groovy:groovy-all:2.4.15'
    }

Run Code Online (Sandbox Code Playgroud)

项目


    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.1'
            classpath 'com.google.gms:google-services:4.3.4'
    
            // NOTE: do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }

Run Code Online (Sandbox Code Playgroud)

Mer*_*eo4 22

嗯,我刚刚遇到了类似的问题,实际上 Gradle 的反馈真的很糟糕。由于“android”块内的一些无效声明,它失败了。

在您的情况下,这似乎只是因为您分配给的值不在versionName(双)引号内,而字符串必须在引号内。

因此,在您的 :app gradle 文件中,只需修复此问题:

android {
    ...
    defaultConfig {
        ...
        versionName '5.0'
        ...
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)


Vij*_*y E 7

另一种可能性是您可能在 android 标签内使用某些插件的属性,该插件未声明为插件。就我而言,我试图使用

firebaseCrashlytics {
                // If you don't need crash reporting for your debug build
                mappingFileUploadEnabled false
            }
Run Code Online (Sandbox Code Playgroud)

不使用下面的插件

apply plugin: 'com.google.firebase.crashlytics'
Run Code Online (Sandbox Code Playgroud)

只需添加插件即可解决问题。另请查找双引号和单引号字符串