尝试使用Java 1.8类时,Android Studio会提示“类需要API级别24(当前最小值为1)”

时间:2016-07-24 19:24:02

标签: android api google-app-engine java-8

我正在尝试使用Java 1.8中的java.util.function Consumer类,但Android Studio正在提示

类需要API级别24(当前最小值为1)

App Engine不应该与Android API有任何关系,因此我不知道为什么会这样做。

有谁知道如何克服错误?谢谢!

编辑(完成Gradle):

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

repositories {
  jcenter();
}

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

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.38'
  testCompile 'junit:junit:4.12'
  testCompile 'com.google.appengine:appengine-testing:1.9.38'
  testCompile 'com.google.appengine:appengine-api-stubs:1.9.38'
  compile group: 'com.googlecode.junit-toolbox', name: 'junit-toolbox', version: '1.5'
  compile 'com.google.appengine:appengine-endpoints:1.9.38'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.38'
  compile 'com.googlecode.objectify:objectify:5.1.5'
  compile 'org.json:json:20151123'
  compile 'javax.servlet:servlet-api:2.5'
  compile 'org.apache.httpcomponents:httpclient:4.5.2'
  compile 'com.ganyo:gcm-server:1.0.2'
  compile 'com.google.appengine.tools:appengine-gcs-client:0.4.4'
  compile 'commons-fileupload:commons-fileupload:1.3.1'
  compile 'com.google.apis:google-api-services-storage:v1-rev66-1.21.0'
}

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

  httpAddress = "0.0.0.0"

  jvmFlags = ['-Ddatastore.backing_store="/Users/jwu/StudioProjects/ProjectBoon2/local_db.bin']
}

1 个答案:

答案 0 :(得分:0)

编辑gradle以使用API​​级别24,然后同步项目。