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

生成时出错。gradle:没有方法的签名:build\u 2gzryvmsr2xvhzda2muxrnzeq。android()适用于参数类型

朱睿
2023-03-14

我试图像这样定义产品风格,但在相同的地方也会出现错误:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.test.test"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    dataBinding {
        enabled = true
    }
    buildTypes {
        release {
            debuggable false
            useProguard true
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    flavorDimensions 'default'
    productFlavors {
        uat {
            applicationId "com.test.test"
            versionCode 1
            versionName "1.0.0"
            buildConfigField "String", 'HOST', '""'
            resValue 'string', 'app_name', "Test"
            isDefault.set(true)
        }
        prod {
            applicationId "com.test.test"
            versionCode 1
            versionName "1.0.0"
            buildConfigField "String", 'HOST', '""'
            resValue 'string', 'app_name', "Test"
        }
    }
    aaptOptions {
        cruncherEnabled = false
    }
    lintOptions {
        checkReleaseBuilds false
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    //Resize library
    implementation 'com.intuit.sdp:sdp-android:1.0.6'

    //Spinkit
    implementation 'com.github.ybq:Android-SpinKit:1.4.0'

    //Kotlin Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"

    //Retrofit & GSON Parsing
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okio:okio:2.8.0'
    implementation(platform("com.squareup.okhttp3:okhttp-bom:4.4.1"))
    implementation("com.squareup.okhttp3:okhttp")
    implementation("com.squareup.okhttp3:okhttp-urlconnection")
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
    implementation "com.squareup.moshi:moshi-adapters:1.5.0"
}

这就是错误

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

有人能帮我吗?

提前谢谢。

共有1个答案

梅欣然
2023-03-14

问题就在这里:

    buildTypes {
    release {
        debuggable false
        useProguard true
        minifyEnabled false
        shrinkResources false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

删除useProguard true问题将得到解决

 类似资料: