有没有办法解决 Gradle 同步失败:启动失败:使用 Volley 时?



我在互联网上阅读了一个教程,如何在Android studio中分享偏好。我收到错误

Gradle sync failed: startup failed:
build file 'D:praktikumbuild.gradle': 11: unexpected 
token: com.android.volley:1.1.0 @ line 11, column 24.
Implementation 'com.android.volley:1.1.0'

NDK Resolution Outcome: Project settings: Gradle model 
version=5.4.1, NDK version is UNKNOWN

首先,我已将其从compile 'com.android.volley:volley:1.1.0'更改为implementation 'com.android.volley:volley:1.1.0',但仍然出现错误

这是我的 gradle 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项:

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
implementation 'com.android.volley:volley:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

您必须在模块级 gradle 文件中声明此依赖项。

正如您在代码中清楚地看到的那样。

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

把它放进去

implementation 'com.android.volley:volley:1.1.0'

模块:应用级构建.gradle

从项目级别 build.gradle 中删除

Implementation 'com.android.volley:1.1.0'

build.gradle (Module: app)中添加此依赖项

并从此处删除

dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
X implementation 'com.android.volley:volley:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

相关内容

最新更新