Android app engine backend entity upload

meguli

I am trying to follow the tutorial given at; https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial

I am also modifying it for my needs along the way. I managed to follow the tutorial project but when I tried my own entity classes in the backend, I get some errors. For example;

Here is the entity class I created called User;

@Entity
public class User {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
private String name;
private String imageType;
private Blob image;

public Key getKey() {
    return key;
}
public String getName() {
    return this.name;
}

public String getImageType() {
    return imageType;
}

public byte[] getImage() {
    if (image == null) {
        return null;
    }
    return image.getBytes();
}

public void setName(String name) {
    this.name = name;
}

public void setImageType(String imageType) {
    this.imageType = imageType;
}

public void setImage(byte[] bytes) {
    this.image = new Blob(bytes);
}
}

Then I am defining an AsyncTask as it is explained in the tutorial. I want to take a photo, capture its path in the device and upload that photo to Datastore. Here is my doInBaackground method;

@Override
protected Void doInBackground(Void... params) {
    User user = new User();
    user.setName("Burak Çopur");
    Userendpoint.Builder builder = new Userendpoint.Builder(
            AndroidHttp.newCompatibleTransport(), 
            new JacksonFactory(),
            null);

    builder = CloudEndpointUtils.updateBuilder(builder);
    Userendpoint endpoint = builder.build(); 
    try {
        endpoint.insertUser(user).execute();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

Finally I call this after camera activity returns like following;

@Override
protected void onActivityResult(int requestCode, int resultCode, 
    Intent data) {
    // Handle activity resulting from IMAGE_CAPTURE
    if(requestCode == REQUEST_IMAGE_CAPTURE){
        new UserTask().execute(getApplicationContext());
        File myFile = new File(mCurrentPhotoPath);
        if(myFile.exists())
            myFile.delete();
    }
}

I checked some similar questions but I could not find the solution. I want to see name field stored first. Then I can move on. Here is the part of error code I am getting;

07-22 02:21:28.941: W/System.err(4852): 
  com.google.api.client.googleapis.json.GoogleJsonResponseException: 
503 Service Unavailable

And here is the problematic line of code;

endpoint.insertUser(user).execute();

I am not trying to do this in local debug server as it is explained in the tutorial. I wanted to see how it works on cloud so deployed my backend project through eclipse. My admin page says my app is running. I also set LOCAL_ANDROID_RUN to false so that it won't try to use local debug server. May problem be that I am not calling new EndpointsTask().execute(); from onCreate method as it is done in the tutorial? Some of the past questions may suggesting something like this but I can't see the reason.

Thanks for any help.

meguli

I think I got this. This is actually pretty straightforward. If you are getting this error, that means you backend connection is problematic. Most of the time, it is because you did not provide full information about your project while generating the backend. Make sure you have entered;

-API key from you project page's Credentials

-Project number

-Project name

-Project version

correctly. Othervise you are out of luck. Or you can also work on local server by following the tutorial given at my original post. In either case, make sure to comment out the section specified in the tutorial. I don't know why but it does not work otherwise.

Also you might be trying to store a data type that is not supported by the Datastore API. For that look at;

com.google.appengine.api.datastore.DataTypeUtils

Storing a Blob that is bigger than 1MB is also not allowed. These are all the bits that I can find about this problem. Make sure you have a valid connction with your backend and make sure you satisfy above rules.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android app engine backend entity upload

From Dev

Retrieving Entity from Google App Engine backend to Android App

From Dev

Retrieving Entity from Google App Engine backend to Android App

From Dev

Android backend: Google App Engine vs Compute engine

From Dev

Android backend: Google App Engine vs Compute engine

From Dev

Upload File - Android to Google App Engine (PHP)

From Dev

Adding a "Shared" module to Android app with App Engine Endpoint backend

From Dev

Deploy Google App Engine backend from Android Studio

From Dev

Add new endpoint to existing App Engine backend server in Android Studio

From Dev

App engine cloud endpoints backend and android in the same maven project

From Dev

Android push notification with Google Cloud Messaging and Google App Engine as backend

From Dev

Where does Android Studio hide upload permissions for an app engine project?

From Dev

No Response on Google App Engine Java Blobstore Upload from Android

From Dev

How to create an Android app connected with Google Cloud SQL in the backend instead of the App Engine datastore?

From Dev

Upload images to Google App Engine

From Dev

Google App Engine upload fail

From Dev

Android app with python backend

From Dev

Backend for Android app

From Dev

Google App Engine backend service(module) with Java

From Dev

Upload photos from Android app to Google Cloud Storage/App Engine - illegal character '_'

From Dev

Deploy Failed when Deploy on google App Engine (for upload on app engine)

From Dev

Android/iOS app with Django as backend

From Dev

Connecting Python Backend to Android APP

From Dev

Google App Engine: Best practice for routing and segmenting an app backend (Python)

From Dev

Google App Engine: Failing to Upload Data

From Dev

Upload File from App Engine to Google Drive

From Dev

Upload image with google app engine fails

From Dev

Upload and read CSV file in google app engine

From Dev

Should I verify the OAuth2 token in the Android client or will App Engine itself authenticate user based on the credential passed to the backend API?

Related Related

  1. 1

    Android app engine backend entity upload

  2. 2

    Retrieving Entity from Google App Engine backend to Android App

  3. 3

    Retrieving Entity from Google App Engine backend to Android App

  4. 4

    Android backend: Google App Engine vs Compute engine

  5. 5

    Android backend: Google App Engine vs Compute engine

  6. 6

    Upload File - Android to Google App Engine (PHP)

  7. 7

    Adding a "Shared" module to Android app with App Engine Endpoint backend

  8. 8

    Deploy Google App Engine backend from Android Studio

  9. 9

    Add new endpoint to existing App Engine backend server in Android Studio

  10. 10

    App engine cloud endpoints backend and android in the same maven project

  11. 11

    Android push notification with Google Cloud Messaging and Google App Engine as backend

  12. 12

    Where does Android Studio hide upload permissions for an app engine project?

  13. 13

    No Response on Google App Engine Java Blobstore Upload from Android

  14. 14

    How to create an Android app connected with Google Cloud SQL in the backend instead of the App Engine datastore?

  15. 15

    Upload images to Google App Engine

  16. 16

    Google App Engine upload fail

  17. 17

    Android app with python backend

  18. 18

    Backend for Android app

  19. 19

    Google App Engine backend service(module) with Java

  20. 20

    Upload photos from Android app to Google Cloud Storage/App Engine - illegal character '_'

  21. 21

    Deploy Failed when Deploy on google App Engine (for upload on app engine)

  22. 22

    Android/iOS app with Django as backend

  23. 23

    Connecting Python Backend to Android APP

  24. 24

    Google App Engine: Best practice for routing and segmenting an app backend (Python)

  25. 25

    Google App Engine: Failing to Upload Data

  26. 26

    Upload File from App Engine to Google Drive

  27. 27

    Upload image with google app engine fails

  28. 28

    Upload and read CSV file in google app engine

  29. 29

    Should I verify the OAuth2 token in the Android client or will App Engine itself authenticate user based on the credential passed to the backend API?

HotTag

Archive