So it looks like android can swap out dex files at...
# android
s
So it looks like android can swap out dex files at runtime via the DexClassLoader. React Native allows downloading new code and swapping it out, which seems like a great way to force updates for an app. Why aren't their libraries for this on Android? This seems very useful. Is there something I'm not realizing?
😶 3
z
One issue with this is you’re adding features in your app that hasn’t been approved by Google yet, thus bypassing their review. It’s probably not widely used in native apps to prevent a ban
e
https://support.google.com/googleplay/android-developer/answer/9888379?hl=en
An app distributed via Google Play may not modify, replace, or update itself using any method other than Google Play's update mechanism. Likewise, an app may not download executable code (e.g. dex, JAR, .so files) from a source other than Google Play.
you can still do so in development, just don't ship it to the play store. https://engineering.fb.com/2018/02/28/android/hotswap-bringing-hot-code-reloading-to-buck/
s
How do react native apps circumvent this then?
Apple has even shown indirectly that they are OK with react native apps updating themselves
e
This restriction does not apply to code that runs in a virtual machine and has limited access to Android APIs (such as JavaScript in a webview or browser).
the Javascript in React Native apps is running in a sandbox (even it it has some holes poked in it for access to some native API)
s
that seems unfair
I’d really like to get an APK approved and then have the same code that was approved auto download and run on my old applications automatically
e
- always have code in your apps so that you can force them to die or require upgrade - can use in-app upgrade: https://developer.android.com/guide/playcore/in-app-updates