vt-cwalker
vt-cwalker

Reputation: 805

Google Endpoints Android with Python Backend

OK. So Ive researched this for days and cannot find an answer that solves my problem. I have a Google App Engine Python project that I have been working on for a couple months for school and now I wish to add an Android app to go along with it. I have created an API server in Python that works in Javascript and on API console. I have ran the command "endpointscfg.py get_client_lib java -o . [my_module.MyApi]" and it generated a .zip file with [projectName]-[Api]-v1-20131104131234-java-1.17.0-rc-sources.jar. I added this to my new Android Project's libs/ directory and added a reference to it in build path. I also can see the [Api] name package when importing. However, when trying to instantiate an object from my API, it does not find anything from my API. How do I instantiate objects that I wrote in my Python API in an Android project if that sources.jar file doesnt contain it? Thanks!

Upvotes: 4

Views: 715

Answers (1)

bao
bao

Reputation: 176

What this *-sources.jar currently has is source code of your client library, and you need to build it by yourself in one Java project. One way to do that is to follow the instruction in this page https://developers.google.com/appengine/docs/java/endpoints/consume_android

This document is sort of out-of-date, since you are now using Google Java Client version 1.17.0-rc, instead of 1.12.0. What you need to do basically is to 1) unzip the source jar, 2) add the source code into one java project; 3) add library dependency into your project libs directory and classpath; 4) build the project, and probably make it as a dependency project of your real android project.

That might take you a lot of time. So another way to do that is to generate a Maven/Gradle client bundle from endpointscfg.py command. What you can do is to add "-bs=maven" or "-bs=gradle" in your command ("bs" option is available since App Engine SDK 1.8.6: https://developers.google.com/appengine/docs/python/endpoints/endpoints_tool). You will get a "smaller" Maven/Gradle client bundle. By following the instruction inside the readme.html file inside the bundle, you get some idea about how to call your API inside your Android project. This is much easier, simply run "mvn install" and add Maven/Gradle dependency into your Android project, if you are using Maven or Gradle in your Android project, which I would recommend.

Upvotes: 3

Related Questions