在迁移过程中,当我使用android studio 3.1.4构建项目时遇到此错误。
原因:com.google.api.client.http.HttpResponseException:500内部服务器错误 {“错误”:{“消息”:“内部服务器错误”,“代码”:500,“错误”:[{“消息”:“未知异常”,“ debug_info”:“未定义servicePath或rpcPath。” }]}}
我遵循了这些:
https://cloud.google.com/endpoints/docs/frameworks/java/migrating https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin
“我的应用”无法访问用于迁移前评估的后端API(api)。
这是我的gradle配置:
API(api)
buildscript { // Configuration for building
repositories {
mavenCentral()
jcenter() // Bintray's repository - a fast Maven Central mirror & more
}
dependencies {
// App Engine Gradle plugin
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
// Endpoints Frameworks Gradle plugin
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
// [END buildscript]
repositories { // repositories for Jar's you access in your code
mavenCentral()
jcenter()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
// [START apply_plugins]
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
// [END apply_plugins]
dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'jstl:jstl:1.2'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '+'
// Uncomment to use Endpoints Frameworks v1.0 and comment the v2.0 section
// compile group: 'com.google.appengine', name: 'appengine-endpoints', version: '+'
// End of Endpoints Frameworks v1.0
// Endpoints Frameworks v2.0
// [START endpoints-tools]
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '2.0.8'
// [END endpoints-tools]
// End of Endpoints Frameworks v2.0
compile 'com.google.inject:guice:4.0'
compile 'com.twilio.sdk:twilio-java-sdk:4.4.5'
compile 'org.json:org.json:chargebee-1.0'
compile 'com.sendgrid:sendgrid-java:2.2.2'
compile 'org.ocpsoft.prettytime:prettytime:3.2.5.Final'
compile 'org.apache.commons:commons-io:1.3.2'
compile 'org.json:json:20140107'
}
appengine { // App Engine tasks configuration
deploy { // deploy configuration
version = findProperty("appengine.deploy.version")
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
}
// [START endpoints-server]
endpointsServer {
// Endpoints Framework Plugin server-side configuration
hostname = "dhobiapp.appspot.com"
}
// [END endpoints-server]
group = 'com.initial.dhobiapprest' // Generated output GroupId
version = '1' // Version in generated output
sourceCompatibility = 1.8 // App Engine Standard uses Java 7
targetCompatibility = 1.8 // App Engine Standard uses Java 7
App Gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
// V2: Add the new Endpoints Framework plugin dependencies
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
android {
signingConfigs {
release {
release {
keyAlias "xyz"
keyPassword ""
storeFile file("/Users/shashankpratap/Androidappkeys/xyz.jks")
storePassword ""
}
}
}
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "com.test"
minSdkVersion 15
targetSdkVersion 28
versionCode 14
versionName "2.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//implementation project(path: ':api', configuration: 'android-endpoints')
implementation project(path: ':api', configuration: 'default')
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.android.volley:volley:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0'
implementation group: 'com.google.api-client', name: 'google-api-client-android', version: '1.22.0'
endpointsServer project(path: ':api', configuration: 'endpoints')
compile 'com.google.api-client:google-api-client:1.23.0'
compile 'com.google.http-client:google-http-client-android:1.23.0'
}
请帮助我解决此错误。我对此一无所知。
谢谢, 伙计们
答案 0 :(得分:0)
如果您在后端API中使用Guice,则Google为此提供了单独的解决方案,请点击此链接,然后应解决该问题。 https://cloud.google.com/endpoints/docs/frameworks/java/using-guice
谢谢。