Reputation: 116
Six months ago, I wrote my Google Cloud Endpoints (GCE) as a module of my Android project on Android Studio (following this tutorial) , everything was going right, but the last week I had to make some significant changes on my API, so I followed the recommendations of the 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 the Android app, it seems that the generated .jar of the API is for the first version, because the method I added doesn´t appear. On the web rest console of the API everything is ok, I can access both versions of the API.
This is my build.gradle configuration for the android app module, I don't know if I can set 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've been looking if anyone else has had this problem, but the closest I found was this question, but I'm not using Maven.
Hope someone can help me.
Upvotes: 3
Views: 354
Reputation: 345
I was having the same problem and did as suggested on the github link's answers:
1) specify a different namespace with a "v2" identifier while preserving the characteristics from the 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 the new class in 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 reorganize my imports as the new jars were now being generated in in /client-libs and I just had to make sure my classes used them. Since the v1 class of my api still exists I can now use either Api depending on which classes I import on each of the working classes in my project.
Credit goes to the users that replied on @loosebazooka's link :)
Upvotes: 2