【问题标题】:Android Studio GAE Project Deploy: Class file is Java 8 but max supported is Java7Android Studio GAE 项目部署:类文件为 Java 8,但最大支持为 Java7
【发布时间】:2017-01-25 22:52:01
【问题描述】:

我在 Android Studio 中有一个 Google App Engine 项目。在过去,我已经成功地将我的项目部署到 GAE 很多次。但是,某些项目设置已更改,我无法再部署。我收到消息:

java.lang.IllegalArgumentException: Class file is Java 8 but max supported is Java 7: javax/ws/rs/ApplicationPath.class in /Users/rob/AndroidStudioProjects/SpeedyMovingInventory/backend/build/exploded-app/WEB-INF/lib/javax.ws.rs-api-2.1-m02.jar
Unable to update app: Class file is Java 8 but max supported is Java 7: javax/ws/rs/ApplicationPath.class in /Users/rob/AndroidStudioProjects/SpeedyMovingInventory/backend/build/exploded-app/WEB-INF/lib/javax.ws.rs-api-2.1-m02.jar
Please see the logs [/var/folders/cn/3ktx4pj50hs7338v88b0sckh0000gn/T/appcfg3087406806803083082.log] for further information.

我尝试在我的build.gradle中设置源和目标兼容性,如下图:

// 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.34'
    }
}

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.34'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.34'
    compile 'joda-time:joda-time:2.8.2'
    compile 'net.sargue:mailgun:1.0.0'
    compile 'com.google.code.gson:gson:2.7'
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    // Set this dependency if you want to use Hamcrest matching
    testCompile 'org.hamcrest:hamcrest-library:1.1'
    testCompile fileTree(include: ['*.jar'], dir: '/Users/rob/appengine-java-sdk-1.9.34/lib/impl')
    testCompile fileTree(include: ['*.jar'], dir: '/Users/rob/appengine-java-sdk-1.9.34/lib/testing')
}


appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }

}

我还使用 Android Studio 生成了示例 GAE 模块并成功将示例部署到 GAE。我比较了 gradle 文件和设置,没有发现任何差异。请帮忙,我做错了什么?

【问题讨论】:

    标签: google-app-engine android-studio


    【解决方案1】:

    经过大量研究,我想出了一个解决办法。库 'net.sargue:mailgun:1.0.0' 显然对 java 8 库(或类似的东西)有某种依赖。我不知道为什么这在过去没有给我造成问题,但现在是。将库升级到“net.sargue:mailgun:1.3.2”解决了这个问题。

    【讨论】:

      【解决方案2】:

      我曾与 mailgun 库的作者进行过对话: https://github.com/sargue/mailgun/issues/11

      他有一个已更新到 Java 8 的依赖项,他在新版本中修复了它。

      【讨论】:

        猜你喜欢
        • 2017-03-21
        • 1970-01-01
        • 2017-08-14
        • 2017-01-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多