【问题标题】:Could not find method dependenciesInfo() for arguments Android找不到参数 Android 的方法 dependenciesInfo()
【发布时间】: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,但没有帮助。

【问题讨论】:

    标签: kotlin android-gradle-plugin build.gradle gradle-dependencies android-studio-4.0


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-20
      • 2019-03-25
      • 2019-12-13
      • 1970-01-01
      • 2019-06-16
      相关资源
      最近更新 更多