未找到 Gradle DSL 方法:'implementation()'

问题描述 投票:0回答:1

问题如下

未找到 Gradle DSL 方法:'implementation()'

可能原因:

您的项目可能使用不包含该方法的 Android Gradle 插件版本(例如 1.1.0 中添加了“testCompile”)。

将插件升级到8.2.0版本并同步项目

打开 Gradle 包装文件

应用 Gradle 插件

build.gradle(模块:应用程序)

plugins {
    id 'com.android.application'
    id('androidx.navigation.safeargs')
    id('dagger.hilt.android.plugin')
}

android {
    namespace 'com.mucahit.kisileruygulamasi'
    compileSdk 34

    buildFeatures{
        viewBinding = true;
    }

    defaultConfig {
        applicationId "com.mucahit.kisileruygulamasi"
        minSdk 24
        targetSdk 34
        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
    }
}

dependencies {
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.7.5'
    implementation 'androidx.navigation:navigation-ui:2.7.5'
    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    implemantation("com.google.dagger:hilt-android:2.44")
    annotationProcessor("com.google.dagger:hilt-android-compiler:2.44")
}

build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    dependencies {
        classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3")
        classpath("com.google.dagger:hilt-android-gradle-plugin:2.44")

    }
}
plugins {
    id 'com.android.application' version '8.2.0' apply false
    id 'com.android.library' version '8.2.0' apply false
}

我认为build.gradle(Module.app)->中有一个错误

plugins {     ...     id('dagger.hilt.android.plugin') }

dependencies {
    ...

    implemantation("com.google.dagger:hilt-android:2.44")
    annotationProcessor("com.google.dagger:hilt-android-compiler:2.44")
}

我想同步,但遇到错误。

java android gradle syntax-error mobile-application
1个回答
0
投票

implemantation()
替换为
implementation()
m
后面的字母是
e
,而不是
a

© www.soinside.com 2019 - 2024. All rights reserved.