Gradle失败 - 无法找到方法com.google.common.io.CharSource.readLines

时间:2016-05-28 09:21:28

标签: android google-app-engine android-studio gradle android-gradle

尝试将android studio中的java版本从jdk1.8更改为jdk 1.7时出现此错误。

错误:

  Error:Unable to find method com.google.common.io.CharSource.readLines'(Lcom/google/common/io/LineProcessor;)Ljava/lang/Object;'.
  Possible causes for this unexpected error include:

Gradle Error

  • Gradle的依赖缓存可能已损坏(这有时会在网络连接超时后发生。)    重新下载依赖项和同步项目(需要网络)
  • Gradle构建过程(守护程序)的状态可能已损坏。停止所有Gradle守护进程可以解决此问题。 停止Gradle构建过程(需要重新启动)
  • 您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的Gradle版本不兼容。
如果Gradle进程损坏,您还可以尝试关闭IDE,然后终止所有Java进程。

的build.gradle:

// 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:1.5.0'
        // 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.2'

    defaultConfig {
        applicationId "com.something.something"
        minSdkVersion 21
        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.1.1'
    compile 'com.android.support:design:23.1.1'
    compile project(path: ':backend', configuration: 'android-endpoints')
}

后端

// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
    compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.18'
    compile 'com.google.appengine:appengine-endpoints:1.9.18'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
    compile 'com.googlecode.objectify:objectify:5.0.3'
  compile 'javax.servlet:servlet-api:2.5'
    compile 'com.ganyo:gcm-server:1.0.2'
}

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}

1 个答案:

答案 0 :(得分:1)

guava-16.0.1.jar 或+中添加了重载的readLines(LineProcessor处理器)功能。但 JAVA 1.8.0.25使用 guava-14.0.1.jar 。所以我们需要将JAVA更新为1.8.0.66 (或者更少,但应该更新番石榴罐)。