Search code examples
javaandroidgoogle-cloud-endpoints-v2

Migration Google Endpoint V1 to V2 & Java 7 to Java 8


During migration, I came across this error when I build the project using android studio 3.1.4.

Caused by: com.google.api.client.http.HttpResponseException: 500 Internal Server Error {"error": {"message": "Internal Server Error", "code": 500, "errors": [{"message": "unknown exception", "debug_info": "Neither servicePath nor rpcPath is defined."}]}}

I followed these :

https://cloud.google.com/endpoints/docs/frameworks/java/migrating https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin

My App does not access backend API (api) as it used to assess before migration.

Here are my gradle configuration :

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'

}

Please help me get passed this error. I am clueless about this.

Thanks, Guys


Solution

  • If you are using Guice in your backend API, Google has provided a separate solution for that, please follow this link and the problem should be solved. https://cloud.google.com/endpoints/docs/frameworks/java/using-guice

    Thanks.