我是Android开发的新手。我已经用Android创建了一个新项目,需要将jetbrains公开的库导入到我现有的项目中。当我试图按照公开的入门指南将以下内容添加到build.grade文件时:
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
compile 'org.jetbrains.exposed:exposed:0.10.2'
}我得到以下错误:
Could not find method compile() for arguments [org.jetbrains.exposed:exposed:0.10.2] 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.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
compile 'org.jetbrains.exposed:exposed:0.10.2'
}
task clean(type: Delete) {
delete rootProject.buildDir
}希望有人能帮我。
提前感谢。
发布于 2018-05-22 18:41:19
您应该将此依赖项放在模块级别的build.gradle文件中--默认情况下,它位于app文件夹中,而不是项目级别的build.gradle文件,后者位于项目的根目录中。
另外,您应该使用implementation而不是compile,因为您使用的是比3.0版本更新的Android插件:
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
implementation 'org.jetbrains.exposed:exposed:0.10.2'
}https://stackoverflow.com/questions/50474422
复制相似问题