Gradle 在对象…DefaultDependencyHandler上找不到参数[…]的方法实现()

Gradle 在对象…DefaultDependencyHandler上找不到参数[…]的方法实现(),gradle,gradle-plugin,Gradle,Gradle Plugin,我发现这是一个常见的错误: “在org.gradle.api.internal.artifacts.dsl.dependency.DefaultDependencyHandler类型的对象上找不到参数[com.github.mik3y:usb serial for android:3.3.0]的方法实现() 但是没有一个正常的解决方案对我有效 build.gradle: buildscript { repositories { jcenter() goog

我发现这是一个常见的错误: “在org.gradle.api.internal.artifacts.dsl.dependency.DefaultDependencyHandler类型的对象上找不到参数[com.github.mik3y:usb serial for android:3.3.0]的方法实现()

但是没有一个正常的解决方案对我有效

build.gradle:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        implementation 'com.github.mik3y:usb-serial-for-android:3.3.0'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url 'https://jitpack.io' }
    }
}
app.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    buildToolsVersion '29.0.3'

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 29
        consumerProguardFiles 'proguard-rules.pro'
        
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments = [                    // Raspi   Windows   LinuxVM   ...
                'rfc2217_server_host': '192.168.0.100',
                'rfc2217_server_nonstandard_baudrates': 'true',   // true    false     false
        ]
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation "androidx.annotation:annotation:1.1.0"
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'commons-net:commons-net:3.6'
    androidTestImplementation 'org.apache.commons:commons-lang3:3.11'
//    implementation 'com.github.mik3y:usb-serial-for-android:3.3.0'
}
gradle-wraper.properties:

#Tue Oct 13 21:20:09 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
通常的解决方案是获得更新的gradle和更新的gradle插件。但我有最新的版本。有没有一个新的解决方案,我不知道


thanx,mike

构建脚本
块中定义的依赖项仅支持
类路径
配置,因此
实现
被拒绝,并显示您提供的错误消息。类路径依赖项仅对构建脚本本身可用。通常,它们提供额外的功能,例如通过添加额外的插件。请在此处阅读更多信息:

也就是说,需要在
buildscript
块之外定义才能工作

dependencies {
    implementation 'com.github.mik3y:usb-serial-for-android:3.3.0'
}
这是您在app.gradle中注释掉的内容