Backend not in sync with the main app in Android Studio

175 views Asked by At

I have added a Google Cloud backend module to my app. It worked fine till yesterday. After that it suddenly refused to recognize any change I make to the backend classes. For example, I have a model class "Match" in my backend which had methods like setId, getId etc. In the app module, I had imported the Match class and used it's methods as well. Then yesterday, I added a new method to this class, "getText". But this method didn't show up in the app module auto-complete and showed "cannot resolve symbol 'getText'" error if I try to forcefully use this. I thought it may be a sync issue, so I did the following (many times in different orders):

  • Build Project
  • Clean Project
  • Run backend
  • Deploy backend to GAE project
  • Sync project with Gradle files
  • Invalidate caches/Restart...
  • removed and added again the import statement for Match class and then did a rebuild
  • Created a fresh project from scratch, added a backend and did the same things with default "MyBean" class. Again, it will recognize only the pre-existing methods and no new method I want to add

But the code is unyielding. It seems that the backend classes that the respective app modules are referring to, somehow froze in time. Even if I comment out some of the methods in the Match class, and then rebuild the project, those methods still appear in the app module.

I am using Android Studio 2.1 by the way.

Now just banging my head to the wall.

1

There are 1 answers

0
James Funk On

From the sounds of it, I had this same issue. What I found out in the end is that the front end of the project only gets getters and setters from the backend. Those getters and setters are based on the members of the class on the backend. I'm guessing that you don't have a member in class Match called text, which is why getText() never worked. Also, I bet you deleted/commented out some of the other methods, but didn't remove the corresponding members from the class. Because those members were still there, the frontend class that is compiled creates getters and setters for them.

I don't have any documentation on this at hand, but I've learned to think about the backend classes as json strings that are passed to the front end. Whatever members are there will can be accessed via getter/setter on the front end, but that is it. Any other functions you build are backend access only.