Android Build Shipped to Google Play Loses Data When Users Update

  • 1
  • Problem
  • Updated 5 years ago
  • Acknowledged
We recently shipped version 53 of our app to the Google Play Store. Users have updated from 52 to 53, and now many users are telling us that their data disappeared during the update. The app stores user data locally on the file system as .txt files, and also using localStorage. At present we are definitely hearing that the .txt files disappeared with the upgrade, and we are checking the tickets to learn if localStorage is also gone, not sure at the moment.

I searched the web and I see people saying that if you sign your Android .apk with a different key, this is exactly what will happen. We have not changed our signing key - we only have one key loaded into PhoneGap Build. So that leads me to ask... Could it be that PhoneGap Build had an issue in which a different key was used to sign our .apk file? We use PhoneGap Build and then we download the resulting .apk file and upload it to Google Play for publishing. The .apk file for version 53 of our app was built on Friday, November 6, 2015. Could it be that there was a problem with PhoneGap Build on that day that would have caused this?

Many thanks in advance.
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
  • frustrated

Posted 5 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Without having any clue, I could just suggest: could this recent issue be related?:
http://community.phonegap.com/nitobi/...
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
@Petra thanks but that doesn't seem to be related.

Does anyone know how to obtain an old .apk from the Google Play store? We log into the developer console and we can see our old .apk for version 52, but it does not allow us to download it. If we click "Switch to advanced mode" there is a "Move to Prod" button next to every old version of our .apk. Has anyone ever tried that function?
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
I wound up solving this. Nothing to do with the signing key! Here's the short version...

We are specifying the file plugin without a version number, so PGB changed from using 2.1.1 to 3.0.0. There was a change in 3.0.0 that causes files to be in a different location, rather than the SD card as before. Here is a commit in Git that shows the change:

https://github.com/apache/cordova-plu...

To work around this, we wrote code that accesses the old location of our files and copies them to the new location. To access the old location we used window.resolveLocalFileSystemURI and passed in this path:

file:///storage/emulated/0/myDirectory

Then we looped through those fileEntries and used .moveTo. That did it!

Lastly, it turns out that PGB does not yet support AndroidPersistentFileLocation as a preference in config.xml. That would have helped us, but I'm glad that we are now going with the new location after all.

Hope this helps somebody!
Photo of jcesarmobile

jcesarmobile

  • 283 Posts
  • 40 Reply Likes
yeah, it's a big problem that phonegap build doesn't support AndroidPersistentFileLocation as it has to be set to "Compatibility" if you don't want to break the app. For now I recommend pinning the previous version of the plugin on the config.xml until AndroidPersistentFileLocation is supported
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
If you still have AndroidPersistentFileLocation set in your app, can you post your app ID?

-yiming
Photo of Alan Neveu

Alan Neveu, Champion

  • 213 Posts
  • 11 Reply Likes
I still have it in mine, but I have gone the other way and specified "Internal". This is because we chose to go with the new behavior and write code that moves files from the old location to the new location. (It is impossible to write code that uses "Compatibility" and copies files from the new location to the old location because apps do not have access to that new location unless PhoneGap gives the app access, and using "Compatibility" is going to negate that possibility.)

That said, yes, in our app we have AndroidPersistentFileLocation set to Internal. If that helps you test, let me know and I will give you our app ID.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
My testing shows that PGB correctly copies the AndroidPersistentFileLocation value from your uploaded config.xml. This appears to be a plugin issue, based on this: https://github.com/apache/cordova-plugin-file/commit/44df96f0985ff7f65cbadbf0543082150fe405f1

-yiming