代码之家  ›  专栏  ›  技术社区  ›  shank2111

将googleendpointv1迁移到V2&将java7迁移到java8

  •  0
  • shank2111  · 技术社区  · 7 年前

    在迁移过程中,我在使用androidstudio3.1.4构建项目时遇到了这个错误。

    原因:com.google.api.client.http.HttpResponseException异常:500内部服务器错误 {“error”:{“message”:“Internal Server error”,“code”:500,“errors”:[{“message”:“unknown exception”,“debug\u 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
    

    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'
    
    }
    

    请帮我通过这个错误。我对此一无所知。

    伙计们

    1 回复  |  直到 7 年前
        1
  •  0
  •   shank2111    7 年前

    如果你在你的后台API中使用Guice,Google已经提供了一个单独的解决方案,请点击这个链接,这个问题应该会得到解决。 https://cloud.google.com/endpoints/docs/frameworks/java/using-guice