【发布时间】:2017-03-11 07:46:48
【问题描述】:
我正在尝试通过 https://github.com/wealdtech/hawk 进行 Hawk 身份验证。我想将这个库按源代码包含在一个空项目中,以便我可以试验 api。我不想使用 jar 或 gradle 依赖项。
我将项目作为模块导入并遇到此错误:
Error:(2, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'HawkTest' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
我尝试了这些链接的解决方案,但无法获得任何有助于解决此问题的信息: Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
我在这个问题上花了很多时间,但似乎还没有找到解决办法。任何方向或解决方案将不胜感激。
这是我的顶级构建文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.test.android.hawktest"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
Hawk 模块的 gradle 文件:
dependencies {
compile 'com.wealdtech:wealdtech-core:2.0.0'
compile 'com.wealdtech:wealdtech-configuration:2.0.0'
compile 'com.google.guava:guava:17.0'
}
uploadArchives {
repositories {
mavenDeployer {
pom.project {
pom.artifactId = 'hawk-core'
name 'Hawk Core'
description 'Java implementation of Hawk protocol - core'
}
}
}
}
还有我的目录结构:
【问题讨论】:
标签: android android-gradle-plugin