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

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

尝试将 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 的依赖缓存可能已损坏(这有时会在网络连接超时后发生。) 重新下载依赖和同步项目(需要网络)
  • 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
  }
}

最佳答案

guava-16.0.1.jar 或 + 中添加了重载的 readLines(LineProcessor 处理器) 函数。但是 JAVA 1.8.0.25 使用 guava-14.0.1.jar。所以我们需要将 JAVA 更新到 1.8.0.66(或更低版本,但应该更新 guava jar)。

关于android - Gradle 失败 - 无法找到方法 com.google.common.io.CharSource.readLines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37497308/

相关文章:

android - 我怎样才能清除这个通知

java - 为什么 App Engine 上的 JRuby 应用程序需要很长时间才能启动(与 Python 应用程序相比)?

python - 在 appspot 上使用旧版本的 Google 应用引擎

Android Studio 和 Dexguard

java - 当没有 Internet 连接时在 GridView 中返回 NullPointerException 时出现问题

android - 错误:请在Android模拟器中更新您的Google Play服务(版本应为10.2.0)

android - 半透明导航,无布局显示在状态栏下方

android - PdfDocument - 在布局末尾剪切页面

java - 平板电脑布局定义

python - 将 OAuth Python 服务与 Google App Engine 结合使用