Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Dev Client Unstable when using Background Tasks: ClassNotFoundException: host.exp.exponent.taskManager.ExpoHeadlessAppLoader #9415

Closed
michaelkleinhenz opened this issue Jul 27, 2020 · 8 comments

Comments

@michaelkleinhenz
Copy link

馃悰 Bug Report

Summary of Issue

The Android Expo client gets unstable when using background tasks. From the first time a client app with background tasks is started inside the client, the client gets unstable and crashes on start (even before getting to the app selector screen). Aparrently, sometimes it can get to the app selector and selection of an app is possible. After that, the app runs stable until the next restart.

The adb log on a crash looks this:

07-27 09:15:53.816  6576  6657 E Expo    : Cannot initialize app loader. host.exp.exponent.taskManager.ExpoHeadlessAppLoader
07-27 09:15:53.816  6576  6657 W System.err: java.lang.ClassNotFoundException: host.exp.exponent.taskManager.ExpoHeadlessAppLoader
07-27 09:15:53.816  6576  6657 W System.err: 	at java.lang.Class.classForName(Native Method)
07-27 09:15:53.816  6576  6657 W System.err: 	at java.lang.Class.forName(Class.java:454)
07-27 09:15:53.816  6576  6657 W System.err: 	at java.lang.Class.forName(Class.java:379)
[...]

As the app can be started after multiple tries and runs stable after that, I assume this is some kind of race condition. Note: the crash appears before getting to the app selector screen, so I guess it is not an issue with the client app(s).

Also, the issue does not appear in a built standalone app, only in the Expo client. The client is nearly unusable due to this issue.

Environment - output of expo diagnostics & the platform(s) you're targeting

Expo CLI 3.22.1 environment info:
    System:
      OS: Linux 5.6 Fedora 32 (Workstation Edition) 32 (Workstation Edition)
      Shell: 5.0.17 - /bin/bash
    Binaries:
      Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node
      Yarn: 1.22.4 - ~/.nvm/versions/node/v14.5.0/bin/yarn
      npm: 6.14.5 - ~/.nvm/versions/node/v14.5.0/bin/npm
    npmPackages:
      expo: ^38.0.8 => 38.0.8 
      react: ~16.11.0 => 16.11.0 
      react-dom: ~16.11.0 => 16.11.0 
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2 
      react-native-web: ~0.11.7 => 0.11.7 
    npmGlobalPackages:
      expo-cli: 3.22.1

Android device is a OnePlus 6, Android 10, Expo client version 2.16.1.

Reproducible Demo

Steps to Reproduce

Create an app with a background task. The background task pulls in Location info. Run it in the Android client.

Expected Behavior vs Actual Behavior

Expected: run the app without issue and stable on reloads. Actual: Expo client is crashing on startup, crashing on client app startup, crashing at app reload. It is crashing all over the place.

@michaelkleinhenz michaelkleinhenz added the needs validation Issue needs to be validated label Jul 27, 2020
@michaelkleinhenz
Copy link
Author

michaelkleinhenz commented Jul 27, 2020

Looking into more debugging, it looks like this only appears when using background tasks with Location.startLocationUpdatesAsync(). I removed the location update and replaced it with an example background fetch and the client runs stable.

@mbretter
Copy link

I can confirm this, I'm not using the Location.startLocationUpdatesAsync(), our app just reads and writes from Async storage using the background-fetch module.
I can reproduce it by following these steps:

  • start your app as usual from the dev env
  • send the app into the background, until the background task runs, everything is working so far
  • terminate the app and expo, the background task still runs, but expo crashes:
07-27 14:49:00.030 25501 25501 E Expo    : Cannot initialize app loader. host.exp.exponent.taskManager.ExpoHeadlessAppLoader
07-27 14:49:00.030 25501 25501 W System.err: java.lang.ClassNotFoundException: host.exp.exponent.taskManager.ExpoHeadlessAppLoader
07-27 14:49:00.030 25501 25501 W System.err: 	at java.lang.Class.classForName(Native Method)
07-27 14:49:00.031 25501 25501 W System.err: 	at java.lang.Class.forName(Class.java:453)
07-27 14:49:00.031 25501 25501 W System.err: 	at java.lang.Class.forName(Class.java:378)
07-27 14:49:00.031 25501 25501 W System.err: 	at l.d.a.b.a(AppLoaderProvider.java:2)
07-27 14:49:00.031 25501 25501 W System.err: 	at l.d.a.b.b(AppLoaderProvider.java:2)
07-27 14:49:00.031 25501 25501 W System.err: 	at expo.modules.taskManager.TaskService.getAppLoader(TaskService.java:2)
07-27 14:49:00.031 25501 25501 W System.err: 	at expo.modules.taskManager.TaskService.executeTask(TaskService.java:17)
07-27 14:49:00.031 25501 25501 W System.err: 	at expo.modules.taskManager.Task.execute(Task.java:2)
07-27 14:49:00.031 25501 25555 W com.amplitude.api.DeviceInfo: Google Play Services not available
07-27 14:49:00.031 25501 25501 W System.err: 	at abi38_0_0.expo.modules.backgroundfetch.BackgroundFetchTaskConsumer.didExecuteJob(BackgroundFetchTaskConsumer.java:1)
07-27 14:49:00.031 25501 25501 W System.err: 	at expo.modules.taskManager.TaskService.handleJob(TaskService.java:7)
07-27 14:49:00.031 25501 25501 W System.err: 	at expo.modules.taskManager.TaskJobService.onStartJob(TaskJobService.java:3)
07-27 14:49:00.031 25501 25501 W System.err: 	at android.app.job.JobService$1.onStartJob(JobService.java:62)
07-27 14:49:00.031 25501 25501 W System.err: 	at android.app.job.JobServiceEngine$JobHandler.handleMessage(JobServiceEngine.java:108)
07-27 14:49:00.031 25501 25501 W System.err: 	at android.os.Handler.dispatchMessage(Handler.java:106)
07-27 14:49:00.031 25501 25501 W System.err: 	at android.os.Looper.loop(Looper.java:280)
07-27 14:49:00.031 25501 25501 W System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6706)
07-27 14:49:00.031 25501 25501 W System.err: 	at java.lang.reflect.Method.invoke(Native Method)
07-27 14:49:00.031 25501 25501 W System.err: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
07-27 14:49:00.031 25501 25501 W System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
07-27 14:49:00.031 25501 25501 W System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "host.exp.exponent.taskManager.ExpoHeadlessAppLoader" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/host.exp.exponent-n3YnG-ZfhnPSIRKhQPYKPA==/base.apk"],nativeLibraryDirectories=[/data/app/host.exp.exponent-n3YnG-ZfhnPSIRKhQPYKPA==/lib/arm64, /data/app/host.exp.exponent-n3YnG-ZfhnPSIRKhQPYKPA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
07-27 14:49:00.031 25501 25501 W System.err: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
07-27 14:49:00.031 25501 25501 W System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    System:
      OS: Linux 4.15 Ubuntu 18.04.4 LTS (Bionic Beaver)
      Shell: 4.4.20 - /bin/bash
    Binaries:
      Node: 10.21.0 - /usr/bin/node
      Yarn: 1.22.4 - /usr/bin/yarn
      npm: 6.14.5 - /usr/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 4.0 AI-193.6911.18.40.6514223
    npmPackages:
      expo: ^38.0.8 => 38.0.8 
      react: 16.11.0 => 16.11.0 
      react-dom: 16.11.0 => 16.11.0 
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz => 0.62.2 
      react-native-web: ~0.11.7 => 0.11.7 
    npmGlobalPackages:
      expo-cli: 3.21.13


@Aryk
Copy link

Aryk commented Aug 24, 2020

They say this issue is fixed in SDK 39 but I haven't seen anyone verify it. Can someone from Expo comment on this issue...it's pretty severe.

Made a forum posting trying to get some clarity on where this is at:

https://forums.expo.io/t/startlocationupdatesasync-crashes-app-on-sdk-38-android-managed/42035

@Obversity
Copy link

Still experiencing this issue myself in the Android client, and I believe it's affecting my app in production as well, where some users are experiencing crashes, which can only be solved by reinstalling the app.

image

@miroslavskela
Copy link

I have upgraded expo to 39, and this issue still causes problems, few problems. First is like @mbretter said, when you kill process expo, or even .apk fails, and there is no way you can start them again, unless you clear storage, second one is that when I start app first time, after install .apk, locations are not working, then when i logout, and login again it start working. Can someone from expo tell us something more about this?

@MahefaAbel
Copy link

MahefaAbel commented Oct 1, 2020

I'm too on expo 39 and have this error, and not still resolved

@umarpazir11
Copy link

I am getting this one
java.lang.RuntimeException: Unable to start activity ComponentInfo{host.exp.exponent.MainActivity}: java.lang.RuntimeException: NativeModuleDepsProvider could not find object for class class host.exp.exponent.kernel.Kernel

@brentvatne
Copy link
Member

hello! the specific issue mentioned in the OP (ClassNotFoundException: host.exp.exponent.taskManager.ExpoHeadlessAppLoader) has been resolved in the SDK 39 patch release on October 3: #10464 (comment)

if you encounter other related issues after updating to the latest version then please let us know in a new issue with all of the relevant error information that we request.

@expo expo locked and limited conversation to collaborators Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants