Perché viene visualizzato errore in Android durante l'inserimento dei dati utilizzando gli endpoint di Google App Engile?

Sto accedendo agli endpoint del progetto android. Il progetto App Engine è stato implementato con successo.

Ecco il mio codice Android:

  • Android Studio dice di utilizzare Gradle 1.10 - ma la nuova versione è 1.12?
  • Inserisci un database nell'APAP di un'applicazione distribuita
  • Activity.runOnUiThread di Android non è statica, quindi come posso utilizzarlo?
  • Creazione di tabelle SQLite da asset HTML di Android
  • Eclipse - Target "sconosciuto" nel dispositivo di scansione Android
  • Formato della barra di scorrimento di Android ScrollView
  • Usermasterendpoint.Builder endpointBuilder = new Usermasterendpoint.Builder(AndroidHttp.newCompatibleTransport(), new JacksonFactory(), new HttpRequestInitializer() { public void initialize(HttpRequest httpRequest) { } }); Usermasterendpoint endpoint = CloudEndpointUtils.updateBuilder( endpointBuilder).build(); System.out.println("End of Asynk Task is...................///////////"); try { UserMaster userManager = new UserMaster();//.setDescription("Note Description"); String userID = new Date().toString(); userManager.setUserID(userID); userManager.setEmail(Email); userManager.setUsername(username); userManager.setPassword(password); UserMaster UsermanagerResult = endpoint.insertUserMaster(userManager).execute(); 

    Ecco la mia class di entity framework; UserMaster. Quello che sto cercando di utilizzare dal codice Android android.

     package com.jay.myapp.dao; //********************************************************************************************************* //Author - Jay //Description - This class is Data Access Object (DAO) for UserMasterDao entity // - Class is basically business class and mostly related to GAE/web application //********************************************************************************************************* import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Query; import java.util.logging.Logger; import com.google.appengine.api.users.User; import com.jagdish.mydprapp.model.UserMaster; import com.jagdish.mydprapp.model.EMF; public enum UserMasterDao { INSTANCE; private static final Logger log = Logger.getLogger(UserMasterDao.class.getName()); //***************************************************************************************************** //getUserByUsermasterID - This method will return List of users or user by getUserByUsermasterID //***************************************************************************************************** @SuppressWarnings("unchecked") //Suppress warning for getResultList() public List<UserMaster> getUserByUsermasterID(Long usermasterID) { log.info("Inside getUserByUsermasterID"); EntityManager em = EMF.get().createEntityManager(); // Read the existing entries Query q = em.createQuery("select t from UserMaster t where t.usermasterID = :usermasterID"); q.setParameter("usermasterID", usermasterID); List<UserMaster> userlist = q.getResultList(); log.info("returning userlist"); return userlist; } //***************************************************************************************************** //addUser - This method will add User to //***************************************************************************************************** public void addUser(String userID, String employeeID, String mediamasterID, User user, String username, String password, String passwordhintquestion, String passwordhintanswer, String firstname, String lastname, String email, Long primaryphone, Long secondaryphone, Long primarymobile, Long secondarymobile, String gender, Long birthdate, String registrationID, String paypalID, String creditcardname, String creditcardnumber, String creditcardexpiration, String creditcardcvccode, String creditcardtype, boolean activeflag, String updatedby, String dateadded, String dateupdated, String comments) { synchronized (this) { log.info("Inside addUser"); EntityManager em = EMF.get().createEntityManager(); //get current date time Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a"); String formattedDate = sdf.format(date); //using user1 object variable instead of user - conflict issue with constructor UserMaster user1 = new UserMaster(userID, employeeID, mediamasterID, user, username, password, passwordhintquestion, passwordhintanswer, firstname, lastname, email, primaryphone, secondaryphone, primarymobile, secondarymobile, gender, birthdate, registrationID, paypalID, creditcardname, creditcardnumber, creditcardexpiration, creditcardcvccode, creditcardtype, activeflag, updatedby, formattedDate, formattedDate, comments); em.persist(user1); em.close(); log.info("User added to UserMaster" + user1); } } //***************************************************************************************************** // createDefaultUser //***************************************************************************************************** public void createDefaultUser(User user, UserMaster appUser, GenericDao<UserMaster> userDao) { //get current date time Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a"); String formattedDate = sdf.format(date); log.info("current date time " + formattedDate); appUser = new UserMaster(user.getUserId(),"na","na",user, "na","na", "na", "na", user.getNickname(), "na", user.getEmail(), 0L, 0L, 0L, 0L, "na", 0L, "na", user.getEmail(), "na", "na", "na", "na", "na", true, user.getUserId(), formattedDate, formattedDate, "na"); userDao.put(appUser); } //***************************************************************************************************** //removeUser - This method will remove User from table //***************************************************************************************************** public void removeUser(Long usermasterID) { EntityManager em = EMF.get().createEntityManager(); try { log.info("Inside removeUser"); UserMaster user = em.find(UserMaster.class, usermasterID); em.remove(user); log.info("User entry deleted"); } finally { em.close(); } } } //end of class 

    Controlla l'errore che riceve:

     09-04 14:42:55.946: W/System.err(1603): com.google.api.client.googleapis.json.GoogleJsonResponseException: 503 Service Unavailable 09-04 14:42:55.946: W/System.err(1603): { 09-04 14:42:55.946: W/System.err(1603): "code" : 503, 09-04 14:42:55.946: W/System.err(1603): "errors" : [ { 09-04 14:42:55.946: W/System.err(1603): "domain" : "global", 09-04 14:42:55.956: W/System.err(1603): "message" : "java.lang.NullPointerException", 09-04 14:42:55.956: W/System.err(1603): "reason" : "backendError" 09-04 14:42:55.956: W/System.err(1603): } ], 09-04 14:42:55.956: W/System.err(1603): "message" : "java.lang.NullPointerException" 09-04 14:42:55.956: W/System.err(1603): } 09-04 14:42:55.956: W/System.err(1603): at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:111) 09-04 14:42:55.956: W/System.err(1603): at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:38) 09-04 14:42:55.986: W/System.err(1603): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312) 09-04 14:42:55.986: W/System.err(1603): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1042) 09-04 14:42:55.986: W/System.err(1603): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) 09-04 14:42:55.986: W/System.err(1603): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) 09-04 14:42:55.986: W/System.err(1603): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460) 09-04 14:42:55.996: W/System.err(1603): at com.jagdish.mydprapp.model.UserManagerAccessorClass.doInBackground(UserManagerAccessorClass.java:57) 09-04 14:42:55.996: W/System.err(1603): at com.jagdish.mydprapp.model.UserManagerAccessorClass.doInBackground(UserManagerAccessorClass.java:1) 09-04 14:42:56.007: W/System.err(1603): at android.os.AsyncTask$2.call(AsyncTask.java:287) 09-04 14:42:56.026: W/System.err(1603): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 09-04 14:42:56.026: W/System.err(1603): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 09-04 14:42:56.037: W/System.err(1603): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 09-04 14:42:56.037: W/System.err(1603): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 09-04 14:42:56.046: W/System.err(1603): at java.lang.Thread.run(Thread.java:856) 

    Aiutaci a risolvere il problema. Grazie in anticipo!!!

  • Generare google-services.json per Android
  • Mostra tastiera soft anche se è collegata una tastiera hardware
  • Scaricare i file e memorizzarli localmente con Phonegap / jQuery Mobile Android e iOS Apps
  • Devo creare un servizio per il monitoraggio GPS APP?
  • Ottieni il codice di stato di risposta utilizzando Retrofit 2.0 e RxJava
  • Cosa succede se un servizio viene avviato più volte?
  • One Solution collect form web for “Perché viene visualizzato errore in Android durante l'inserimento dei dati utilizzando gli endpoint di Google App Engile?”

    Ho la risposta che devi controllare l'id di generazione automatica del tempo è nullo o no. Mi stava dando la prima volta. Basta aggiungere un'istruzione if nella mia class endpoint nel progetto del motore App. nella class endpoint otterrai

     containsYourEntityClass(YourEntityClass xyz) . 

    Devi aggiungere

     if(YourEntityClass.getxxxID() == null) return false; 

    L'integer codice è

     private boolean containsYourEntityClass(YourEntityClass xyz) { EntityManager mgr = getEntityManager(); boolean contains = true; try { if(xyz.getxxxID() == null) return false; YourEntityClass item = mgr.find(YourEntityClass.class, xyz.getxxxID()); if (item == null) { contains = false; } } finally { mgr.close(); } return contains; } 

    L'Android è un fan Android di Google, tutto su telefoni Android, Android Wear, Android Dev e applicazioni Android Games e così via.