The goal
The goal is to remove deprecated code that is auto-generated by Android Studio. I only want my entities in the project, no depreciated dependencies. I will add push notifications through Google Cloud Messaging library.
Q: Which code is deprecated?Q/A
A: Any generated code that depends on com.google.android.gcm is deprecated.
Generating initial backend and client libraries
- Open an existing Android project
- Let's call it Project
- Let's assume that the package name is com.example.package
- Generate App Engine Backend
- Tools -> Google Cloud Tools -> Generated App Engine Backend
- This will create two projects:
- Project-AppEngine
- Project-endpoints
Cleanup
- Delete
- Under Project-AppEngine
- google_generated
- target
- Under Project-AppEngine/src/main/java/com.example.package
- Device*.java
- Message*.java
- From Project-AppEngine/src/main/webapp/index.html
- scripts
- content of the <body/> tag
- add something like <h1>Sample Project</h1> under <body/>
- Under Project-endpoints/src/endpoint-src/java
- com.example.package
- Under Project-endpoints/src/main
- com.example.package
- From Project-endpoints/src/main/AndroidManifest.xml
- GCMIntentService
- GCMBroadcastReceiver
- RegisterActivity
- More stuff can be removed from this file, like unused permissions.
- From Project-endpoints/build.gradle
- compile files('libs/gcm.jar')
- more dependencies can be removed from this file
- Under Project-endpoints/libs
- gcm.jar
Adding Entities and deploying
- Add a test entity under Project-AppEngine/src/main/java/com.example.package
- Test.java
- Generate TestEndpoint.java
- Select Test.java
- Tools -> Google Cloud Tools -> Generate Endpoint
- Deploy the project to GAE
- Maven Projects -> Project-AppEngine/Plugins/appengine/appengine:update
- At this point you can interact with TestEndpoint in APIs Explorer
Client libraries
- Generate client libraries
- Select Project-AppEngine
- Tools -> Google Cloud Tools -> Generate Client Libraries
- Synchronize the project (refresh)
- This step creates
- Project-AppEngine/google_generated
- Project-AppEngine/target/Project-
AppEngine-1.0
- Nothing is yet created under Project-endpoints/src/endpoint-src/java
- Generate client libraries - AGAIN!
- Select Project-AppEngine
- Tools -> Google Cloud Tools -> Generate Client Libraries
- Synchronize the project (refresh) - AGAIN!
- Look under Project-endpoints/src/endpoint-src/java/com.example.project.testendpoing
- On the second attempt the client code for TestEndpoint is generated
- Now this code can be used in the original Android Project to communicate with GAE.
Notes
When you add a new entity under Project-AppEngine/src/main/java/com.example.package, the step of generating client libraries has to be performed twice, at least at the moment.
- First run will modify Project-AppEngine
- Second run will generate client code under Project-endpoints
Hopefully this will be fixed in the future.
No comments:
Post a Comment