【问题标题】:Android Studio error - groovy.lang.MissingMethodException: No signature of method: build_8sqj**q9.android() is applicable for argument types: ***Android Studio 错误 - groovy.lang.MissingMethodException:没有方法签名:build_8sqj**q9.android() 适用于参数类型:***
【发布时间】:2021-04-24 11:50:46
【问题描述】:

我在 android studio 中准备了一个 android 应用程序,然后我将整个代码从一个系统手动复制到另一个系统。但在那之后,得到这个错误。 下面是我的 gradle 文件和屏幕截图。(不知道为什么清单文件没有显示在 android studio 中,这可能是相关的) 请不要标记副本,因为我已经尝试了许多来自 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'
    }

项目


    // 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
    }

【问题讨论】:

    标签: java android-studio gradle


    【解决方案1】:

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

    在您的情况下,这似乎只是因为您分配给 versionName 的值没有像字符串一样包含在(双)引号内。

    所以,在你的 :app gradle 文件中,修复这个:

    android {
        ...
        defaultConfig {
            ...
            versionName '5.0'
            ...
        }
        ...
    }
    

    【讨论】:

    • 嗨,我在添加 proguard 文件时遇到了这个问题,请指导我这里的问题是我的 proguard 文件 minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules .pro'
    • @Adnanhaider 如果没有更多信息,我无法回答您,但您也许应该创建一个新问题,因为这可能与其他问题有关。就像您的 proguard 文件中的配置错误一样。
    【解决方案2】:

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

    firebaseCrashlytics {
                    // If you don't need crash reporting for your debug build
                    mappingFileUploadEnabled false
                }
    

    不使用下面的插件

    apply plugin: 'com.google.firebase.crashlytics'
    

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

    【讨论】:

      【解决方案3】:

      在 build.gradle 的 android {} 块中声明的任何内容都可能导致此构建失败。

      除了其他答案提到的内容外,请查找任何非 Gradle 参考。

      例如,我的构建失败的原因是以下几行:

      buildToolsVersion = '30.0.3'
      installation {
          installOptions '-d', '-t'
          timeOutInMs '2 * 60 * 1000'
      }
      

      删除它们后,构建成功。

      【讨论】:

        猜你喜欢
        • 2017-06-19
        • 1970-01-01
        • 2017-07-05
        • 1970-01-01
        • 2021-07-31
        • 1970-01-01
        • 2021-10-02
        • 2021-11-02
        • 1970-01-01
        相关资源
        最近更新 更多