找不到参数Android的方法dependencyInfo

问题描述

App Build Android Studio错误

 Could not find method dependenciesInfo() for arguments
 [build_7pycm2rxdjt52mhv3k1evqwie$_run_closure1$_closure9@1e56c29c] on
 object of type
 com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
 Open File

失败了

这是我的build.gradle(应用级别)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

android {    
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.xxx.xxx.xxx"

        minSdkVersion 17
        targetSdkVersion 29

        versionCode 3011
        versionName "1.2.02"

        vectorDrawables.useSupportLibrary = true
        resConfigs "en"

        multiDexEnabled true
    }
 
    aaptOptions {
        cruncherEnabled false
    }

    dataBinding {
        enabled = true
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true

       proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
            debuggable false
            jniDebuggable false
            renderscriptDebuggable false
            pseudoLocalesEnabled false
            zipAlignEnabled true
        }

        debug {
            debuggable true
            jniDebuggable true
            renderscriptDebuggable true
            minifyEnabled false
            zipAlignEnabled false   
        }
    }

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

dependenciesInfo {
            // disables dependency Metadata when building APKs.
            includeInApk = false
            // disables dependency Metadata when building Android App Bundles.
            includeInBundle = false
        }
    }

dependencies {
    implementation filetree(dir: 'libs',include: ['*.jar'])

    //Android X dependencies
    implementation 'androidx.appcompat:appcompat:1.2.0-beta01'

    implementation 'androidx.browser:browser:1.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "androidx.constraintlayout:constraintlayout:1.1.3"

    //Android Architecture Components
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'

    //Firebase dependencies
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-messaging:17.3.3'

    //com.google dependencies
    implementation 'com.google.android.gms:play-services-ads-lite:16.0.0'
    implementation "com.google.android.material:material:1.1.0"

    //other library gradle
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    implementation 'com.android.volley:volley:1.1.1'

    kapt 'androidx.room:room-compiler:2.2.5'
    implementation 'androidx.room:room-runtime:2.2.5'

    implementation 'io.github.inflationx:calligraphy3:3.1.1'
    implementation 'io.github.inflationx:viewpump:2.0.3'

}

apply plugin: 'com.google.gms.google-services'

我的build.gradle(项目级别)如下:

buildscript { 
    ext.kotlin_version = '1.3.40'

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.26.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

请建议如何解决此问题。

我正在使用Android Studio 4.0。 我尝试使用“无效的缓存”选项重新启动Android Studio,但没有帮助。

解决方法

dependenciesInfo DSL块仅出现在4.0 Gradle插件版本中。您使用3.5.2
classpath 'com.android.tools.build:gradle:3.5.2' 将其更新到4.0