我在互联网上阅读了有关如何在Android Studio中共享偏好设置的教程。我遇到了错误
Gradle sync failed: startup failed:
build file 'D:\praktikum\build.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
}
答案 0 :(得分:0)
您必须在模块级gradle文件中声明此依赖项。
如您在代码中清楚看到的那样。
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
答案 1 :(得分:0)
将其放入
implementation 'com.android.volley:volley:1.1.0'
模块:应用程序级别的build.gradle
从项目级别build.gradle中删除
答案 2 :(得分:0)
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
}