Question

I've been trying to add a Google Cloud Backend to my android application using Android Studio. I've been following along with this I/O talk: http://youtu.be/lmv1dTnhLH4?t=37m2s and I realise that things have changed a bit from back then. In the video, he generates an endpoint be right clicking on a java file like the one below then selecting 'Generate Cloud Endpoint' which produces an endpoint java class he can then use in his app. I'm using Android Studio v0.5.6 and that option doesn't seem to be there any more. It seems all of the Android studio documentation relating to App Engine integration I've found on the internet hasn't been updated. Could anyone point me in the right direction to get this set up using the latest versions of Android Studio.

To add the backend I selected Tools > Google Cloud Tools > Add App Engine Backend:

Steps taken to add backend module

Class I am trying to create an endpoint for:

enter image description here

User class:

package com.test.lol;

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;

import java.util.Date;

@Entity
public class User {

    @Id
    private String mID;
    private String mFirstName;
    private String mLastName;
    private String mEmail;
    private String mBirthday;
    private Date mLastSeen;

    public String getID() {
        return mID;
    }

    public void setID(String ID) {
        this.mID = ID;
    }

    public String getFirstName() {
        return mFirstName;
    }

    public void setFirstName(String firstName) {
        mFirstName = firstName;
    }

    public String getLastName() {
        return mLastName;
    }

    public void setLastName(String lastName) {
        mLastName = lastName;
    }

    public String getEmail() {
        return mEmail;
    }

    public void setEmail(String email) {
        mEmail = email;
    }

    public String getBirthday() {
        return mBirthday;
    }

    public void setBirthday(String birthday) {
        mBirthday = birthday;
    }

    public Date getLastSeen() {
        return mLastSeen;
    }

    public void setLastSeen(Date lastSeen) {
        mLastSeen = lastSeen;
    }
}
Was it helpful?

Solution

Google have acknowledged this feature is missing and are working to implement it.

Source: https://code.google.com/p/android/issues/detail?id=68223

Edit: This feature has been implemented in the beta version of Android Studio

In the mean time, I:

  • Was able to use the Google Endpoint documentation to figure out which annotations to use for the Endpoint API.
  • Checked out the Objectify Documentation to figure out which annotations to use for Entities and Datastore persistance.
  • Uploaded my code to app engine using the terminal command: gradlew appengineUpdateAll
  • Installed the android client libraries to my local Maven repository using the terminal command: gradlew appengineEndpointsInstallClientLibs
  • Followed this tutorial on how to add the google API client to my Gradle project.
  • Added the local Maven repo to my projects build.gradle file and the client library as a dependency in my app's build.gradle
  • Used the Endpoint in my app.
  • Double fist pumped the air with great elation and proclaimed "I am the master commander!"

OTHER TIPS

Finally Google Cloud Backend has been added again in Android Studio 0.6.1: http://android-developers.blogspot.it/2014/06/new-ways-to-connect-your-app-to-the-cloud-android-studio.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top