我使用Android Studio 3.0尝试运行一个appengine模块:
./gradlew :api:endpointsDiscoveryDocs
但返回错误:
Execution failed for task ':api:endpointsDiscoveryDocs'.
> java.lang.ClassNotFoundException: -h
Caused by: java.lang.ClassNotFoundException: -h
at com.google.api.server.spi.tools.GenApiConfigAction.loadClasses(GenApiConfigAction.java:109)
at com.google.api.server.spi.tools.GenApiConfigAction.genApiConfig(GenApiConfigAction.java:90)
at com.google.api.server.spi.tools.GetDiscoveryDocAction.getDiscoveryDoc(GetDiscoveryDocAction.java:78)
at com.google.api.server.spi.tools.GetDiscoveryDocAction.execute(GetDiscoveryDocAction.java:59)
at com.google.api.server.spi.tools.EndpointsTool.execute(EndpointsTool.java:69)
at com.google.cloud.tools.gradle.endpoints.framework.server.task.GenerateDiscoveryDocsTask.generateDiscoveryDocs(GenerateDiscoveryDocsTask.java:137)
有人遇到过这个问题吗? (什么是-h ?!) 这是配置问题吗?我尝试在项目中搜索“ -h”,但没有发现任何异常。有谁知道为什么发生此问题?
顶级build.gradle:
buildscript {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.guava:guava:19.0'
}
}
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
文件api / build.gradle:
buildscript {
repositories {
maven {
url 'https://maven-central.storage.googleapis.com'
}
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
repositories {
maven {
url 'https://maven-central.storage.googleapis.com'
}
jcenter()
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'war'
//apply plugin: 'appengine'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.0'
compile 'jstl:jstl:1.2'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile('com.google.endpoints:endpoints-framework:2.0.9')
compile 'com.googlecode.objectify:objectify:5.1.12'
compile 'com.google.code.gson:gson:2.8.5'
compile group: 'org.tuckey', name: 'urlrewritefilter', version: '4.0.4'
compile group: 'com.google.appengine.tools', name: 'appengine-gcs-client', version: '0.8'
compile group: 'com.google.apis', name: 'google-api-services-oauth2', version: 'v2-rev129-1.22.0'
testCompile 'junit:junit:4.12'
}
configurations.all {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
appengine {
deploy { // deploy configuration
version = findProperty("appengine.deploy.version")
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
//promote = new Boolean(promoteProp)
}
}
//downloadSdk = true
//appcfg {
// oauth2 = true
//}
//endpoints {
// getClientLibsOnBuild = true
// getDiscoveryDocsOnBuild = true
//}
}
endpointsServer {
hostname = "sample.project.hostname"
}
group = "com.test.api.projectname"
version = 1
我不得不在这里问这个问题,谷歌搜索并没有带来任何有用的结果。
答案 0 :(得分:0)
此api build.gradle文件似乎可以解决该问题:
buildscript {
repositories {
maven {
url 'https://maven-central.storage.googleapis.com'
}
jcenter()
mavenCentral()
}
dependencies {
//classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
repositories {
maven {
url 'https://maven-central.storage.googleapis.com'
}
jcenter()
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'war'
//apply plugin: 'appengine'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.0'
implementation 'jstl:jstl:1.2'
implementation group: 'javax.inject', name: 'javax.inject', version: '1'
implementation('com.google.endpoints:endpoints-framework:2.0.9')
implementation 'com.googlecode.objectify:objectify:5.1.12'
implementation 'com.google.code.gson:gson:2.8.5'
implementation group: 'org.tuckey', name: 'urlrewritefilter', version: '4.0.4'
testImplementation 'junit:junit:4.12'
}
configurations.all {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
appengine {
deploy { // deploy configuration
version = findProperty("appengine.deploy.version")
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
//promote = new Boolean(promoteProp)
}
}
//downloadSdk = true
//appcfg {
// oauth2 = true
//}
//endpoints {
// getClientLibsOnBuild = true
// getDiscoveryDocsOnBuild = true
//}
}
endpointsServer {
hostname = "path.to.project.hostname"
}
group = "project.package.name"
version = 1
此依赖项已被注释掉:
//classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'