python - Cannot import google cloud endpoints client library class in Android project -
i'm having difficulty getting google cloud endpoints working. have python endpoints project running on gae , works using api explorer. i'm struggling generate client library , use in android app. i've tried number of sample projects , have same problem every time; can't import , use model classes client libraries.
here's i'm doing (for example i'll use helloworld api python sample @ https://github.com/googlecloudplatform/appengine-endpoints-helloendpoints-python)
- unzip sample code
generate client library navigating folder , running
<gae-sdk>\endpointscfg.py get_client_lib java helloworld_api.helloworldapi
unzip generated folder , copy root of project in eclipse
in eclipse add "your_app_id_appspot_com-helloworld-v1-20140310110152-java-1.17.0-rc-sources.jar" build path (right click jar> build path>add build path)
at stage, can import com.appspot.your_app_id.helloworld.model.*
but cannot import com.appspot.your_app_id.helloworld.model.greeting
can shed light on what's happening here? have tried many different ways work have same problem every time.
many thanks,
tom
the problem default, generated zip file contains sources jar, not actual compiled library jar android app can use.
here's solution:
in backend api folder (from same place app.yaml located), generate client library gradle library, so:
<gae-sdk-path>\endpointscfg.py get_client_lib java -bs gradle helloworld_api.helloworldapi
you'll have helloworld-v1.zip. unzip (either right here or in somewhere convenient ~/temp)
this create folder called helloworld, should have build.gradle in there along src folder.
build client library using "gradle install" in folder.
copy
build/libs/helloworld-v1-1.x.x-snapshot.jar
android app's libs folder.add library in android studio right-click/add-as-library.
your classes should resolve correctly.
step 4 should install just-built client library local maven repository. can follow instructions in readme.html in helloworld/ folder extracted integrate directly android app's gradle build system instead of copying jar built manually.
Comments
Post a Comment