从2.1.2更新Android Studio - > 2.1.3今天早上收到以下gradle sync错误:
错误:无法找到方法 ' org.gradle.api.internal.file.DefaultSourceDirectorySet。(Ljava /郎/字符串; Ljava /郎/字符串; Lorg / gradle这个/ API /内部/文件/ FileResolver;)V'
我非常确定它与以下图书馆项目有关:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
}
}
sourceSets {
main {
proto {
srcDir 'src/main/protos'
}
java {
srcDir 'src/main/java'
}
manifest {
srcFile 'src/main/AndroidManifest.xml'
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile project(':wallpaperpicker-resources')
}
protobuf {
// Configure the protoc executable
protoc {
// Download from repositories
artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
}
}
看起来我以前的gradle插件版本是1.3.0 - 我是否遗漏了与sourceSets块相关的一些更改?
答案 0 :(得分:6)
尝试更新protobuf版本:
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
答案 1 :(得分:3)
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
}
}
apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
}
}
sourceSets {
main {
proto {
srcDir 'src/main/proto'
}
java {
srcDirs = ['src/main/java','$buildDir/generated-sources/release/javalite']
}
manifest {
srcFile 'src/main/AndroidManifest.xml'
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
compile 'com.google.protobuf:protoc-gen-javalite:3.0.0'
compile 'com.google.protobuf:protobuf-lite:3.0.0'
compile project(':wallpaperpicker-resources')
}
protobuf {
generatedFilesBaseDir = "$projectDir/build/generated-sources"
protoc {
// Download from repositories
artifact = 'com.google.protobuf:protoc:3.0.0'
}
plugins {
javalite {
// The codegen for lite comes as a separate artifact
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {
//remove some of the javalite extra packaging
outputSubDir = ''
}
}
}
}
}
apply plugin: 'idea'
idea {
module {
sourceDirs += file("$buildDir/generated-sources/release/javalite");
}
}