Skip to content

[Bug] ORT RN Expo config plugin incompatible with Expo 55+ #28657

@artus9033

Description

@artus9033

Describe the issue

Expo config plugin getPackages() insertion point inside ReactNativeHostWrapper used in Expo <= 54 has been replaced with ExpoReactHostFactory in this commit.

Full error produced when using the ORT RN Expo config plugin with Expo 55:

Error: [android.mainApplication]: withAndroidMainApplicationBaseMod: Failed to match "/override fun getPackages\(\)/" in contents:
package com.anonymous.expoapp

// @generated begin onnxruntime-react-native-import - expo prebuild (DO NOT MODIFY) sync-4543d7f2625243dfdef886002e5bf12df91957f2
import ai.onnxruntime.reactnative.OnnxruntimePackage
// @generated end onnxruntime-react-native-import
import android.app.Application
import android.content.res.Configuration

import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.common.ReleaseLevel
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint

import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ExpoReactHostFactory

class MainApplication : Application(), ReactApplication {

  override val reactHost: ReactHost by lazy {
    ExpoReactHostFactory.getDefaultReactHost(
      context = applicationContext,
      packageList =
        PackageList(this).packages.apply {
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // add(MyReactNativePackage())
        }
    )
  }

  override fun onCreate() {
    super.onCreate()
    DefaultNewArchitectureEntryPoint.releaseLevel = try {
      ReleaseLevel.valueOf(BuildConfig.REACT_NATIVE_RELEASE_LEVEL.uppercase())
    } catch (e: IllegalArgumentException) {
      ReleaseLevel.STABLE
    }
    loadReactNative(this)
    ApplicationLifecycleDispatcher.onApplicationCreate(this)
  }

  override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
  }
}

The new API offers the equivalent functionality with a builder-style DSL insertion point in the packageList parameter of ExpoReactHostFactory.getDefaultReactHost:

ExpoReactHostFactory.getDefaultReactHost(
      context = applicationContext,
      packageList =
        PackageList(this).packages.apply {
          add(OnnxruntimePackage()) // <- this should be injected starting from Expo 55
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // add(MyReactNativePackage())
        }
    )

To reproduce

  1. Create an Expo app with Expo SDK 55
  2. Add onnxruntime-react-native dependency
  3. Add ORT RN Expo config plugin to the app
  4. Try to prebuild the Android app (npx expo prebuild)

Urgency

Users of Expo 55 and above won't be able to use the ORT RN Expo config plugin.

Platform

Android

OS Version

15

ONNX Runtime Installation

Released Package

Compiler Version (if 'Built from Source')

No response

Package Name (if 'Released Package')

onnxruntime-react-native

ONNX Runtime Version or Commit ID

1.24.3

ONNX Runtime API

JavaScript

Architecture

ARM64

Execution Provider

Default CPU

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:Javascriptissues related to the Javascript APIplatform:mobileissues related to ONNX Runtime mobile; typically submitted using templateplatform:webissues related to ONNX Runtime web; typically submitted using template

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions