Rya*_*113 1 android gradle android-studio
我在几个地方看到过这个问题。问题似乎在于更新过去的 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.
Run Code Online (Sandbox Code Playgroud)
这是我的 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')
}
}
Run Code Online (Sandbox Code Playgroud)
我的 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
Run Code Online (Sandbox Code Playgroud)
我很感激任何帮助。一直试图让我的应用程序在 Android 上运行一天。
删除buildscript顶级文件块中的这些行:
//implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
//implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02
Run Code Online (Sandbox Code Playgroud)
您必须在 dependencies在module/build.gradle文件块中。
同时删除dependencies块内的allprojects块
buildscript {
ext {
//...
}
repositories {
//..
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
//..
google()
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1831 次 |
| 最近记录: |