expo / sentry-expo

MIT License
202 stars 83 forks source link

SDK 48 on Android build Failing #342

Closed wcastand closed 1 year ago

wcastand commented 1 year ago

Summary

i'm in a monorepo and the app is building as long as i don't have sentry (locally or dev app) but the preprod is failing with this logs:

> Task :expo-notifications:bundleLibRuntimeToJarRelease
[stderr] 
Note: Some input files use or override a deprecated API.
[stderr] 
Note: Recompile with -Xlint:deprecation for details.
[stderr] 
Note: Some input files use unchecked or unsafe operations.
[stderr] 
Note: Recompile with -Xlint:unchecked for details.
> Task :expo-modules-core:buildCMakeRelWithDebInfo[armeabi-v7a]
> Task :expo-modules-core:configureCMakeRelWithDebInfo[x86]
> Task :app:createBundleReleaseJsAndAssets_SentryUpload_com.greengot.preprod@1.10.7+137_137
Processing react-native sourcemaps for Sentry upload.
> Analyzing 2 sources
> Rewriting sources
> Adding source map references
Uploading sourcemaps for release com.greengot.preprod@1.10.7+137 distribution 137
> Bundled 2 files for upload
> Uploaded release files to Sentry
> File upload complete (processing pending on server)
> Organization: green-got
> Project: retails
> Release: com.greengot.preprod@1.10.7+137
> Dist: 137
Source Map Upload Report
  Minified Scripts
    ~/index.android.bundle (sourcemap at index.android.bundle.map)
  Source Maps
    ~/index.android.bundle.map
> Task :app:createBundleReleaseJsAndAssets_SentryCollectModules_com.greengot.preprod@1.10.7+137_137 FAILED
[stderr] 
node:internal/modules/cjs/loader:988
[stderr] 
  throw err;
[stderr] 
  ^
[stderr] 
Error: Cannot find module '/home/expo/workingdir/build/apps/mobile-app/node_modules/@sentry/react-native/dist/js/tools/collectModules.js'
[stderr] 
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
[stderr] 
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
[stderr] 
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
[stderr] 
    at node:internal/main/run_main_module:22:47 {
[stderr] 
  code: 'MODULE_NOT_FOUND',
[stderr] 
  requireStack: []
[stderr] 
}
> Task :expo-updates:compileReleaseKotlin

this line Error: Cannot find module '/home/expo/workingdir/build/apps/mobile-app/node_modules/@sentry/react-native/dist/js/tools/collectModules.js'

makes me think it's related to this: https://github.com/getsentry/sentry-react-native/pull/3092

I got the error after upgrading to latest sentry version after expo-doctor asked me to.

  "@sentry/react-native": "4.15.2",
  "sentry-expo": "6.2.0",

Before upgrading it was building correctly but i wasn't getting the sourcemaps on sentry.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

48

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.3 Shell: 5.9 - /bin/zsh Binaries: Node: 18.15.0 - ~/Library/Caches/fnm_multishells/1676_1685350404870/bin/node Yarn: 3.6.0 - ~/Library/Caches/fnm_multishells/1676_1685350404870/bin/yarn npm: 9.5.0 - ~/Library/Caches/fnm_multishells/1676_1685350404870/bin/npm Watchman: 2023.03.13.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/lib/ruby/gems/3.1.0/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Android NDK: 22.1.7171670 IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.9971841 Xcode: 14.3/14E222b - /usr/bin/xcodebuild npmGlobalPackages: eas-cli: 3.13.3 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

none

AronBe commented 1 year ago

Also monorepo, if it is relevant, also failing due to this error, sdk 48

wcastand commented 1 year ago

found this that fix it: https://github.com/expo/sentry-expo/issues/292

const { withAppBuildGradle, withPlugins } = require("@expo/config-plugins")

const sentryFix = `project.ext.sentryCli=[collectModulesScript: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../dist/js/tools/collectModules.js")]`

function withSentryMonorepoFix(config) {
    return withAppBuildGradle(config, (config) => {
        config.modResults.contents = `
        ${sentryFix}
        ${config.modResults.contents}
    `
        return config
    })
}

module.exports = (config) => withPlugins(config, [withSentryMonorepoFix])