我已经在多个地方看到了这个问题。问题似乎与过去的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')
}
}
我的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
您必须在
dependencies
文件的module/build.gradle
块中添加这些依赖项。同时删除
dependencies
块内的allprojects
块buildscript {
ext {
//...
}
repositories {
//..
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
//..
google()
jcenter()
}
}
关于android - 找不到参数[androidx.appcompat:appcompat:1.1.0-rc01]的方法Implementation(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58379548/