Android app fails to work offline [SDK 25]

#1

I’ve built my app for Android with SDK 25. Got the APK and installed it on my phone. The app still fails to open for the first time when the user is offline.

As far as I understood from the docs. A version of the JS bundle should be bundled along with the app, along with all the assets specified in app.json.

I tried it on both a Samsung Note 8, and a Nexus 6.

2 Likes
#2

Hey @abdallamohamed - sorry you’re having this issue! Are you bundling any assets with your app by any chance? If so, have you specified assetBundlePatterns as shown in the docs here https://docs.expo.io/versions/latest/guides/offline-support.html#bundle-your-assets-inside-your-standalone-binary ? cc @janic

#3

Thanks for replying, @esamelson

Yes. I’m bundling some fonts and images.

    "assetBundlePatterns": [
      "node_modules/@expo/vector-icons/fonts/*",
      "assets/fonts/*",
      "assets/images/*"
    ],
#5

@abdallamohamed Could you send me the link of your published experience?

Also another thing you could do to help me debug this is to unzip the APK generated by expo and check if the images are contained inside. To do that the easiest way is just to change the extension to .zip and unzip it normally, then the assets should be located inside the assets folder with names like asset_<some-hash>.<extension>.

#6

@janic Thanks for replying. I sent you the link to the app on Expo. And assets seem to be bundled just fine by the way.

#7

I looked at your manifest and everything seems fine. Actually the issue might not be related to asset bundling, does the app manage to load at all? If it’s a bundled asset issue the app should still load fine but assets will be blank.

#8

Another thing I just thought about, could you try removing the splash screen config from app.json, could be related to that not working offline properly.

#9

Yeah if I close the app and clear it from recent apps. Open it again when I’m online, it will work. It also works offline afterwards. It’s that first time that fails if I try to open it when I’m offline

#10

Okay, so that bug has been kind of inconsistent so far, but I managed to find a way to reproduce it. If you install the apk and open the app while offline, it’ll work. I sent you a copy of the apk.

  1. Install the apk and open the app while you’re offline, it will work.
  2. Close the app and remove it from the recent apps list.
  3. Open the app again while also offline, then you’ll see the following error.
Uncaught Error: java.net.UnknownHostException: Unable to resolve host "exp.host": No address associated with hostname

The closes issue I could find on GitHub is that one https://github.com/expo/expo/issues/607

#11

Thanks for the details, I can now repro the bug and will look into it monday!

2 Likes
#12

I am experiencing the same issue my side - SDK24

#13

I’m having the same issue with android standalone build using SDK25.

#14

Any update on this issue?

#15

Sorry about the delay, I just submitted a patch to fix this. It should be fixed in the next sdk release.

2 Likes
#16

You guys are the best!

closed #17

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.