尝试在Android Studio gradle项目中使用spoon框架,但在尝试添加勺子插件时出错:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.4'
}
}
apply plugin: 'android'
apply plugin: 'spoon'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
androidTestCompile 'com.squareup.spoon:spoon-client:1.3.2'
}
错误:(13,0)插件带有id' spoon'找不到
和:
Error:Could not find com.stanfy.spoon:spoon-gradle-plugin:1.0.4.
Searched in the following locations:
file:/C:/Apps/Studio/gradle/m2repository/com/stanfy/spoon/spoon-gradle- plugin/1.0.4/spoon-gradle-plugin-1.0.4.pom
file:/C:/Apps/Studio/gradle/m2repository/com/stanfy/spoon/spoon-gradle-plugin/1.0.4/spoon-gradle-plugin-1.0.4.jar
https://maven.fabric.io/public/com/stanfy/spoon/spoon-gradle-plugin/1.0.4/spoon-gradle-plugin-1.0.4.pom
https://maven.fabric.io/public/com/stanfy/spoon/spoon-gradle-plugin/1.0.4/spoon-gradle-plugin-1.0.4.jar
gradle命令行对此链接的投诉:
答案 0 :(得分:2)
您是否注意到您的项目有两个build.gradle文件?我很确定你添加到一个文件中,这就是你面临的问题
在第一个build.gradle
(app)中,您应该具有以下依赖关系:
apply plugin: 'com.android.application'
apply plugin: 'spoon'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.android.databindingexample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
dataBinding {
enabled = true
}
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.2.0'
compile 'com.android.support:support-v4:23.2.0'
androidTestCompile 'com.squareup.spoon:spoon-client:1.3.2'
}
在第二个build.gradle
文件(yourApplicationName)中,您应该:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha1'
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.4'
// 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
}
希望这会对你有所帮助
答案 1 :(得分:-1)
这对我有用:
dependencies {
classpath 'de.felixschulze.gradle:gradle-spoon-plugin:2.7.3'
}
apply plugin: 'de.felixschulze.gradle.spoon'