Sentry-react-native: [Android] gradle release upload fails

Created on 4 May 2018  路  31Comments  路  Source: getsentry/sentry-react-native

OS:

  • [x] Windows
  • [ ] MacOS
  • [ ] Linux

_Platform:_

  • [ ] iOS
  • [x] Android

Output of node -v && npm -v && npm ls --prod --depth=0

v9.11.1
5.6.0

# I am using Yarn and the NPM output is full of unrelated warnings, so dependencies from package.json

"apollo-cache-inmemory": "^1.1.11",
"apollo-client": "^2.2.7",
"apollo-link": "^1.2.1",
"apollo-link-context": "1.0.7",
"apollo-link-error": "^1.0.7",
"apollo-link-http": "^1.5.3",
"apollo-link-retry": "2.2.2",
"apollo-link-ws": "^1.0.8",
"apollo-utilities": "1.0.11",
"date-fns": "next",
"debug": "3.1.0",
"graphql": "0.12.3",
"graphql-tag": "2.8.0",
"graphql-tools": "^2.22.0",
"mobx": "^4.1.1",
"mobx-react": "^5.0.0",
"mobx-state-tree": "^2.0.3",
"random-js": "1.0.8",
"react": "^16.3.2",
"react-apollo": "^2.1.3",
"react-native": "~0.55.3",
"react-native-easy-grid": "0.1.16",
"react-native-firebase": "3.2.0",
"react-native-image-sequence": "gijoehosaphat/react-native-image-sequence",
"react-native-sentry": "^0.36.0",
"react-native-sound": "^0.10.9",
"react-native-svg": "6.0.1-rc.1",
"react-router-native": "^4.2.0",
"recompose": "0.26.0",
"redbox-react": "1.5.0",
"styled-components": "2.4.0",
"subscriptions-transport-ws": "0.9.7",
"ts-enum-util": "2.0.2",
"verror": "1.10.0"

Config:

Sentry.config(process.env.SENTRY_DSN, {
   logLevel: SentryLog.Debug,
   deactivateStacktraceMerging: Platform.OS === 'android',
}).install()

Release APK (gradlew assembleRelease) is successfully built, but subsequent upload to sentry fails.

Actual result:

 DONE  Built successfully in 64.82s!

Assets location: D:\workspace\project\android\app\build\intermediates\res\merged\release
Bundle location: D:\workspace\project\android\app\build\intermediates\assets\release\index.android.bundle
Executing task ':app:bundleReleaseJsAndAssetsreleaseSentryUpload' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Starting process 'command 'cmd''. Working directory: D:\workspace\project Command: cmd /c node_modules/@sentry/cli/bin/sentry-cli --log-level debug react-native gradle --bundle D:\workspace\project\android\app\build\intermediates\assets\release\index.android.bundle --sourcemap D:\workspace\project\android\app\build\intermediates\assets\release\index.android.bundle.map --release org.my.app-1.0 --dist 1
Successfully started process 'command 'cmd''
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
:app:bundleReleaseJsAndAssets FAILED

Running that generated command was asking for --org and then --project which I added along with auth token and then it finished succesfully. I checked sentry.gradle which adds org/project only if flavorAware is enabled which is strange, but after enabling it and running gradlew assembleRelease again it ends up with a different, even more cryptic error.

 Script 'D:\workspace\project\node_modules\react-native-sentry\sentry.gradle' line: 176

 * What went wrong:
 Execution failed for task ':app:bundleReleaseJsAndAssetsreleaseSentryUpload'.
 > java.lang.NullPointerException (no error message)

 * Exception is:
 org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:bundleReleaseJsAndAssetsreleaseSentryUpload'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:337)
        at org.gradle.api.internal.TaskInternal$execute.call(Unknown Source)
        at sentry_wkf9t4girtt9iyd7pfjye2ee$_run_closure1$_closure4$_closure11.doCall(D:\workspace\project\node_modules\react-native-sentry\sentry.gradle:176)

Steps to reproduce:
That would probably require some repo to reproduce. Basically I run the react-native link react-native-sentry to get wizard autoconfigure it.

What might be worth noting that I am using TypeScript and my entry file is src/index.ts. This is then bundled with HaulJS which is using Webpack underneath, but result bundle works in the application, so it's probably not that relevant.

Expected result:
What more to say, running directly the CLI works, so that will my current workaround for now, but would be nice to have it automated.

Android gradle

Most helpful comment

check if defaults.project in sentry.properties file is exactly the same with name on sentry.io, may be you renamed it after sentry has been installed
for me it fixed the issue

All 31 comments

I am getting the same error. :(

Having this problem now too out of the blue

same.

Same for me too.

Fixing it by changing sentry.properties 'cli.executable' property to:
cli.executable=node_modules/@sentry/cli/bin/sentry-cli
(I had te remove the option upload-dsym from this property)

@Kornflexx But dsym is for iOS. The issue I described above is happening for Android... And I already have the same value for cli.executable in both sentry.properties.

@HazAT
Having the same issue for Android builds both locally and in CI. The same issue happens for iOS as well now both locally and in AppCenter CI. I tried the below settings in the android/app/build.gradle

project.ext.sentryCli = [
    logLevel: "debug",
    flavorAware: false
]

But faced with a 404 error from Sentry

Processing react-native sourcemaps for Sentry upload.
[INFO] sentry_cli::commands::react_native_gradle   bundle path: ****/android/app/build/intermediates/assets/release/index.android.bundle
> Analyzing 2 sources
[INFO] sentry_cli::commands::react_native_gradle   sourcemap path: ****/android/app/build/intermediates/assets/release/index.android.bundle.map
> Rewriting sources
> Adding source map references
[INFO] sentry_cli::api request POST https://sentry.io/api/0/projects/****/****/releases/
[INFO] sentry_cli::api using token authentication
[INFO] sentry_cli::api sending JSON data (68 bytes)
[INFO] sentry_cli::api > POST /api/0/projects/****/****/releases/ HTTP/1.1
[INFO] sentry_cli::api > Host: sentry.io
[INFO] sentry_cli::api > Accept: */*
[INFO] sentry_cli::api > Connection: TE
[INFO] sentry_cli::api > TE: gzip
[INFO] sentry_cli::api > User-Agent: sentry-cli/1.32.0
[INFO] sentry_cli::api > Authorization: Bearer 25507089***
[INFO] sentry_cli::api > Content-Type: application/json
[INFO] sentry_cli::api > Content-Length: 68
[INFO] sentry_cli::api < HTTP/1.1 404 NOT FOUND
[INFO] sentry_cli::api < Server: nginx
[INFO] sentry_cli::api < Date: Tue, 29 May 2018 18:30:01 GMT
[INFO] sentry_cli::api < Content-Type: application/json
[INFO] sentry_cli::api < Content-Length: 14
[INFO] sentry_cli::api < Connection: keep-alive
[INFO] sentry_cli::api < X-XSS-Protection: 1; mode=block
[INFO] sentry_cli::api < Content-Language: en
[INFO] sentry_cli::api < X-Content-Type-Options: nosniff
[INFO] sentry_cli::api < Vary: Accept-Language, Cookie
[INFO] sentry_cli::api < Allow: GET, POST, HEAD, OPTIONS
[INFO] sentry_cli::api < X-Frame-Options: deny
[INFO] sentry_cli::api < X-Served-By: web-c9683d4c
[INFO] sentry_cli::api < Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
[INFO] sentry_cli::api response: 404
error: project not found


FAILURE: Build failed with an exception.

* Where:
Script '****/node_modules/react-native-sentry/sentry.gradle' line: 176

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssetsreleaseSentryUpload'.
> Process 'command 'node_modules/@sentry/cli/bin/sentry-cli'' finished with non-zero exit value 1

@anandwahed How does your sentry.properties file look like?
It seems your project-slug is wrong.

Hi @HazAT below is how the sentry.properties look,

defaults.url=https://sentry.io/
defaults.org=wahedcom-s1
defaults.project=stockfinder
auth.token=****
cli.executable=node_modules/@sentry/cli/bin/sentry-cli

@anandwahed So your org is wrong, it should be wahedtech, where did you copy wahedcom-s1?

@HazAT it was auto-generated since we didn't create these files manually. One issue might be that the org name could have been changed after we had integrated the Sentry SDK. We will try with the updated org name and update you.

@anandwahed OK, if you are renaming your org you have to update your config, this was the issue then.

@HazAT Could you please refocus on the issue at hand? You haven't even responded to anything above.

Also @anandwahed shame on you for hijacking. Make your own issue if you see there is obvious difference :/

@FredyC thanks for you enlightenment. I had posted here because the issue i had was very similar to the one you had mentioned if you see my previous comments. Just because @HazAT replied to me doesn't mean you have to make these unnecessary comments.

Come on guys, everything is fine :)
@FredyC Can you enable verbose logging in gradle?
https://docs.sentry.io/clients/react-native/manual-setup/#android

@HazAT wondering if there has been a resolution for this. I am running into the sane issue both locally and on our CI (we use bitrise). The iOs builds are working and my ios/sentry.properties and android/sentry.properties files are identical.

"react-native": "^0.56.0"
"react-native-sentry": "^0.39.0",

android/sentry.properties
```
defaults.url=https://sentry.io/
defaults.org=the-dyrt
defaults.project=wayfinder
auth.token=馃攽
cli.executable=node_modules/@sentry/cli/bin/sentry-cli

Hi there, I just edited this for you. Please never post your auth token in public places like Github, Stack Overflow or the support forum. Doing so might give others access to sensitive data in your account.

@HazAT To follow up I have tried the suggestions here and that fixes the problem locally. But I do not want to check my .properties files into git and we use CI for releases. We have all sentry variables set as ENV variables but they are not found, the cli still searches for .properties files. Is there a way to use ENV variables for CI builds with product flavors? In the meantime I am running a script to autogenerate those files but it feels a bit clumsy.

I had the same issue. I managed a local workaround by setting a static path to my local sentry cli.executable in 'sentry.properties' (e.g. where it was 'cli.executable=node_modules/@sentry/cli/bin/sentry-cli' I changed to 'cli.executable=C:/Projetos/app/node_modules/@sentry/cli/bin/sentry-cli').

Same :(.

I'm on RN 0.57.5, Windows 10. Running .\gradlew assembleRelease gave me this at the end. What am I missing with it not being able to find/execute sentry cli binary? ('node_modules' is not recognized as an internal or external command...)

I confirmed that \node_modules\react-native-sentry\sentry.gradle exists.

~\WonderSwipe\android> .\gradlew assembleRelease

...

> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
bundle: Writing bundle output to: ~\WonderSwipe\android\app\build\generated\assets\react\release\index.android.bundle
bundle: Writing sourcemap output to: ~\WonderSwipe\android\app\build\generated\assets\react\release\index.android.bundle.map
bundle: Done writing sourcemap output
bundle: Done writing bundle output
bundle: Copying 1 asset files
bundle: Done copying assets

> Task :app:bundleReleaseJsAndAssetsx86-releaseSentryUpload FAILED
'node_modules' is not recognized as an internal or external command,
operable program or batch file.

> Task :app:bundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* Where:
Script '~\WonderSwipe\node_modules\react-native-sentry\sentry.gradle' line: 176

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssetsx86-releaseSentryUpload'.
> Process 'command 'cmd'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 30s
47 actionable tasks: 46 executed, 1 up-to-date

I tried @Victorams's workaround with cli.executable=cli.executable=C:\Users\Gary\Documents\code\WonderSwipe\node_modules\@sentry\cli\bin\sentry-cli in sentry.properties, does not work. Running .\gradlew assembleRelease gave similar error:

'C:UsersGaryDocumentscodeWonderSwipe' is not recognized as an internal or external command,

Interestingly, if I change sentry.properties line to cli.executable=node_modules\@sentry\cli\bin\sentry-cli (forward slash with Windows instead of default back slash), error output change to:

'node_modules@sentryclibinsentry-cli' is not recognized as an internal or external command,

@fungilation @FredyC
On windows you must change and put direct path to sentry executable.
Open ./android/sentry.peropertise :

Delete below line :
cli.executable=node_modules\\@sentry\\cli\\bin\\sentry-cli

And instead of that, put this line:
cli.executable=[YOUR WINDOWS DRIVE:\\YOUR PROJECT PATH]\\node_modules\\@sentry\\cli\\bin\\sentry-cli

Enjoy with my changes :
cli.executable=D:\\Workspace\\Etode\\node_modules\\@sentry\\cli\\bin\\sentry-cli

Thanks @mohammad-goldast!

/me goes off swearing at the stupidity that is Windows CLI

check if defaults.project in sentry.properties file is exactly the same with name on sentry.io, may be you renamed it after sentry has been installed
for me it fixed the issue

Maybe you have changes on the project name, command react-native link react-native-sentry fixed this or as said @vladbars can be changed manually.

304 this fixed the issue for me. just remove the "cli.executable" line, and it will use the defalut path in the "sentry.gradle" file:

            Properties sentryProps = new Properties();
            try {
                sentryProps.load(new FileInputStream(propertiesFile));
            } catch (FileNotFoundException e) {
                println "File not found: $propertiesFile"
            }
            def cliExecutable = sentryProps.get("cli.executable", "$reactRoot/node_modules/sentry-cli-binary/bin/sentry-cli");

this worked on my MacOS, but if you are using Windows10, you need to do like this #91
cli.executable=node node_modules/@sentry/cli/bin/sentry-cli

Closing this for now since I merged the PR for windows support.
https://github.com/getsentry/react-native-sentry/pull/523
Will be included in next release.

I'm still having this issue on Mac OS X when running react-native run-android. Seems related to https://github.com/getsentry/react-native-sentry/issues/539

same issue on Mac

I'm still experiencing this issue with version 0.42.0.

Hitting the NullPointer issue was well

Was this page helpful?
0 / 5 - 0 ratings