找不到参数 Android 的方法 dependenciesInfo()

Posted

技术标签:

【中文标题】找不到参数 Android 的方法 dependenciesInfo()【英文标题】:Could not find method dependenciesInfo() for arguments Android 【发布时间】:2020-12-27 14:56:15 【问题描述】:

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,但没有帮助。

【问题讨论】:

【参考方案1】:

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

【讨论】:

以上是关于找不到参数 Android 的方法 dependenciesInfo()的主要内容,如果未能解决你的问题,请参考以下文章

找不到对象上的参数 [project ':model'] 的方法 api()

Android Studio“找不到参数的方法实现()”

在flutter中找不到参数android()的方法

Gradle - 错误找不到参数的方法 implementation() [com.android.support:appcompat-v7:26.0.0]

在以下类型的对象上找不到参数 [com.android.tools.build:gradle:3.3.0] 的方法 classpath():

Gradle build:找不到参数的方法signingConfig()