找不到参数 [androidx.appcompat:appcompat:1.1.0-rc01] 的方法实现()



我在好几个地方看到过这个问题。问题似乎在于更新过去的 gradle 版本 3 和 android studio 版本 3。每当我将依赖项更改为较新版本时,我都会收到错误:

Could not find method implementation() for arguments [androidx.appcompat:appcompat:1.1.0-rc01] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

这是我的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:3.5.0')
}
}

My gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-5.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

我感谢任何帮助。一直在尝试让我的应用程序在 Android 上运行一天了。

删除顶级文件buildscript块中的这些行:

//implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
//implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02

您必须将这些依赖项添加到module/build.gradle文件的dependencies块中。

同时移除allprojects块内的dependencies

buildscript {
ext {
//...
}
repositories {
//..
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
//..
google()
jcenter()
}
}

相关内容

最新更新