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

BugsnagInstallJniLibsTask crash when tasks.whenTaskAdded exists #373

Open
jiulongw opened this issue Mar 14, 2021 · 3 comments
Open

BugsnagInstallJniLibsTask crash when tasks.whenTaskAdded exists #373

jiulongw opened this issue Mar 14, 2021 · 3 comments
Labels
needs discussion Requires internal analysis/discussion

Comments

@jiulongw
Copy link

I spent a few hours chasing this bug by trial and error. It turns out to be an edge case and can be worked around. Couldn't find any related results in search engines. Hope it can help someone who sees similar error.

Describe the bug

bugsnag-android-gradle-plugin crashes (in BugsnagInstallJniLibsTask) when a react-native project:

  1. has externalNativeBuild defined AND
  2. has another plugin that injects tasks.whenTaskAdded into gradle script. In my case, the react-native-config.

Error message is quite confusing:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/jiulongw/tmp/AwesomeProject/node_modules/@bugsnag/react-native/android/build.gradle' line: 16

* What went wrong:
A problem occurred evaluating project ':bugsnag_react-native'.
> Failed to apply plugin 'com.android.internal.library'.
   > Project#afterEvaluate(Action) on project ':bugsnag_react-native' cannot be executed in the current context.

From stack trace it seems to be related to JNI tasks:

at com.bugsnag.android.gradle.BugsnagInstallJniLibsTask$Companion.resolveBugsnagArtifacts$bugsnag_android_gradle_plugin(BugsnagInstallJniLibsTask.kt:70)
at com.bugsnag.android.gradle.BugsnagPlugin$registerNdkLibInstallTask$ndkSetupTask$1.invoke(BugsnagPlugin.kt:131)
at com.bugsnag.android.gradle.BugsnagPlugin$registerNdkLibInstallTask$ndkSetupTask$1.invoke(BugsnagPlugin.kt:60)

For me, the work around is to simply remove the entire tasks.whenTaskAdded block in react-native-config's dotenv.gradle plugin which I don't need anyway...

Hope gradle expert and find the root cause and fix the problem.

Steps to reproduce

I have create a repo bugsnag-plugin-issue-repro which is a clean project created by npx react-native init, installed bugsnag plugin by npx @bugsnag/react-native-cli init. This is the commit that triggers the crash.

  1. Clone bugsnag-plugin-issue-repro
  2. npm install
  3. cd android && ./gradlew assemble
  4. See error

Environment

  • Android Studio version: N/A
  • Android Gradle version: 6.7
  • Bugsnag manifest section (if modified): N/A
@johnkiely1
Copy link
Member

Hey @jiulongw,

Thanks for raising this, we will take a look and see what we can do about it.

@johnkiely1 johnkiely1 added the needs discussion Requires internal analysis/discussion label Mar 15, 2021
@Ali72
Copy link

Ali72 commented Oct 9, 2021

I have the same issue in a react-native project and get this error:

`A problem occurred evaluating project ':bugsnag_react-native'.

Failed to apply plugin 'com.android.internal.library'.
Gradle#projectsEvaluated(Action) on build '' cannot be executed in the current context.`

react config:
react-native:0.63.4

android config:
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "com.bugsnag:bugsnag-android-gradle-plugin:5.+"

Android Gradle version:6.7.1

@yousif-bugsnag
Copy link

Hi @Ali72, thanks for the report.

That error message looks a little different and is fairly generic, so it's not clear if this is the same situation as the original report.

bugsnag-android-gradle-plugin crashes (in BugsnagInstallJniLibsTask) when a react-native project:

  1. has externalNativeBuild defined AND
  2. has another plugin that injects tasks.whenTaskAdded into gradle script. In my case, the react-native-config.

Are the above conditions also true for your project? Can you share a build output with the --stacktrace option enabled so that we can take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs discussion Requires internal analysis/discussion
Projects
None yet
Development

No branches or pull requests

4 participants