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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find symbol import expo.core.ExpoModulesPackage #2789

Closed
aeftimia opened this issue Dec 22, 2024 · 6 comments
Closed

cannot find symbol import expo.core.ExpoModulesPackage #2789

aeftimia opened this issue Dec 22, 2024 · 6 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@aeftimia
Copy link

Build/Submit details page URL

https://expo.dev/accounts/aeftimia/projects/app/builds/99af3b55-e014-4afe-bbbb-154a92ae3fde

Summary

I'm trying to deploy a minimal react-native-webview project, and eas build seems to fail with this error on gradlew :app:bundleRelease:

> Task :app:compileReleaseJavaWithJavac FAILED
/home/expo/workingdir/build/packages/mobile/app/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:14: error: cannot find symbol
import expo.core.ExpoModulesPackage;
                ^
  symbol:   class ExpoModulesPackage
  location: package expo.core
/home/expo/workingdir/build/packages/mobile/app/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:62: error: cannot find symbol
      new ExpoModulesPackage(),
          ^
  symbol:   class ExpoModulesPackage
  location: class PackageList
2 errors
> Task :expo-modules-core:buildCMakeRelWithDebInfo[armeabi-v7a]
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

I tried installing expo-modules-core as shown in my setup from a blank project. I'm new to this, but I've exhausted my options regarding what else I can find or think of to try.

Managed or bare?

bare

Environment

npx expo-env-info

  expo-env-info 1.2.1 environment info:
    System:
      OS: macOS 15.1.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 23.5.0 - /opt/homebrew/bin/node
      npm: 10.9.2 - /opt/homebrew/bin/npm
    Managers:
      CocoaPods: 1.16.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.2, iOS 18.2, macOS 15.2, tvOS 18.2, visionOS 2.2, watchOS 11.2
    IDEs:
      Android Studio: 2024.2 AI-242.23339.11.2421.12700392
      Xcode: 16.2/16C5032a - /usr/bin/xcodebuild
    npmPackages:
      expo: ~52.0.20 => 52.0.20 
      react: 18.3.1 => 18.3.1 
      react-native: 0.76.5 => 0.76.5 
    npmGlobalPackages:
      eas-cli: 14.2.0
    Expo Workflow: bare

npx expo-doctor

Enabled experimental React Native Directory checks. Unset the EXPO_DOCTOR_ENABLE_DIRECTORY_CHECK environment variable to disable this check.
Running 15 checks on your project...
✔ Check package.json for common issues
✔ Check Expo config for common issues
✔ Check native tooling versions
✔ Check for common project setup issues
✖ Check dependencies for packages that should not be installed directly
✔ Check npm/ yarn versions
✔ Check for issues with Metro config
✔ Check if the project meets version requirements for submission to app stores
✖ Check for app config fields that may not be synced in a non-CNG project
✖ Validate packages against React Native Directory package metadata
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check that packages match versions required by installed Expo SDK
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✔ Check that native modules use compatible support package versions for installed Expo SDK

Detailed check results:


Advice: Add '/android' and '/ios' to your .gitignore file if you intend to use CNG / Prebuild. Learn more: https://docs.expo.dev/workflow/prebuild/#usage-with-eas-build

Advice: 
- Update React Native Directory to include metadata for unknown packages. Alternatively, set expo.doctor.reactNativeDirectoryCheck.listUnknownPackages in package.json to false to skip warnings about packages with no metadata, if the warning is not relevant.

Error output

Task :app:compileReleaseJavaWithJavac FAILED
/home/expo/workingdir/build/packages/mobile/app/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:14: error: cannot find symbol
import expo.core.ExpoModulesPackage;
^
symbol: class ExpoModulesPackage
location: package expo.core
/home/expo/workingdir/build/packages/mobile/app/android/app/build/generated/autolinking/src/main/java/com/facebook/react/PackageList.java:62: error: cannot find symbol
new ExpoModulesPackage(),
^
symbol: class ExpoModulesPackage
location: class PackageList
2 errors
Task :expo-modules-core:buildCMakeRelWithDebInfo[armeabi-v7a]
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

Reproducible demo or steps to reproduce from a blank project

npx install-expo-modules@latest --template blank
npx expo install react-native-webview
npx expo install @react-native/gradle-plugin
npx expo install @babel/runtime
npx expo install expo-asset
npx expo install expo-modules-core
npx expo run --platform android

App.js:

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View } from 'react-native';
import { WebView } from 'react-native-webview';

export default function App() {
  return (
      <WebView 
      style={styles.container}
      source={{ uri: 'https://example.com/' }} >
      <StatusBar style="auto" />
      </WebView>
  );
}

const styles = StyleSheet.create({
  container: {
    marginTop: 10,
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
@aeftimia aeftimia added the needs review Issue is ready to be reviewed by a maintainer label Dec 22, 2024
@aeftimia
Copy link
Author

aeftimia commented Dec 22, 2024

Confirming this also happens without Webview

export default function App() {
  return (
      <View style={styles.container} >
      <StatusBar style="auto" />
      </View>
  );
}

@LongHP105
Copy link

I've got the same problem.
How can I deal with this?

@LongHP105
Copy link

Investigation
The local android build: ✅

  • using import expo.modules.ExpoModulesPackage;

The EAS service build: ❌

  • using import from expo.core.ExpoModulesPackage

@LongHP105
Copy link

@aeftimia
I found that the problem is that my project is using pnpm, so it somehow cannot resolve dependencies correctly.

so if you use pnpm too, maybe this approach you can try:

  • add node-linker=hoisted to .npmrc

It solved my issue.

@aeftimia
Copy link
Author

Thanks! That worked for me too!

@delphinebugner
Copy link

Hi! Also had the issue, unfortunately adding node-linker=hoisted is not possible in my project.

If someone else is in the same situation: you can add in your app package.json:

  • "expo-modules-autolinking": "*"

That will help pnpm finds its way and make the native error disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants