How to access specific versions of the Google Cloud Endpoints API for Android clients
Six months ago I wrote my Google Cloud Endpoints (GCE) as a module of my Android project in Android Studio (after this tutorial ), everything was going right, but last week I had to make some significant changes to my API, so I followed recommendations documentation and create a new version of the API. Now that I have this new version of my API called "v2" I'm not sure how to connect it to my Android app, it seems like the generated .jar API for the first version because the method I added doesn't appear. On the API web console everything is fine, I can access both versions of the API.
This is my build.gradle config for android app module, I don't know if I can install the GCE API version here.
dependencies {
compile project(path: ':googlecloudendpointsapi', configuration: 'android-endpoints')
}
Or in the build.gradle of the endpoints module
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
I searched if anyone else had this problem, but the closest I found is this question , but I am not using Maven.
Hope someone can help me.
source to share
I had the same problem and assumed the answers on github are links:
1) specify a different namespace with id "v2" while keeping the characteristics from v1 (this would be optional):
@Api(
version = "v2",
namespace = @ApiNamespace(
ownerDomain = "mypackage.com",
ownerName = "MyCompany",
packagePath = "backend/v2")
)
@ApiReference(MyEndpoint.class)
public class MyEndpointV2 {
...
}
2) Add a new class to src / main / webapp / WEB-INF / web.xml:
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>
com.mypackage.backend.MyEndpoint,
com.mypackage.backend.MyEndpointV2,
...
3) Finally, I just had to refactor my imports as new jars are now created in / client -libs and I just needed to make sure my classes were using them. Since the ap1 class of my api still exists, I can now use either the Api, depending on which classes I import for each of the worker classes in my project.
Credit goes to users who replied to @loosebazooka link :)
source to share