bugsnag / bugsnag-expo

MIT License
11 stars 5 forks source link

Building Android with EAS Build, the build fails due to Gradle with Bugsnag #110

Closed amalasyrafs closed 1 year ago

amalasyrafs commented 1 year ago

Describe the bug

When I try to run EAS build on Android, I'm getting this error message.

`Running 'gradlew :app:bundleRelease' in /home/expo/workingdir/build/android Downloading https://services.gradle.org/distributions/gradle-7.5.1-all.zip 10% 20%. 30 %. 40% 50 %. 60%. 70%. 80%. 90 %. 100% Welcome to Gradle 7.5.1! Here are the highlights of this release:

I tried removing bugsnag package from my project, and the build works. I have also tried downgrading bugsnag package to version 44 ( this is my last project version before bumping up Expo SDK) and the build works.

It seems like expo build is on SDK 47 is using Gradle 7.5.1.

My project have these dependencies from bugsnag: "@bugsnag/expo": "^47.0.0", "@bugsnag/plugin-expo-eas-sourcemaps": "^47.0.0", "@bugsnag/source-maps": "^2.3.1",

Steps to reproduce

Im not sure to report to expo or bugsnag but since the error seems like caused by bugsnag specifically, I decided to report here instead.

Environment

amalasyrafs commented 1 year ago

I guess worth also mentioning that when I build on Android with the same package version on Dec 2022, the build works.

Im not sure why bugsnag expect gradle version 8.

amalasyrafs commented 1 year ago

Update: the build works when remove @bugsnag/plugin-expo-eas-sourcemaps package. My guess is that it expect Gradle 8 as per the error.

thorbenprimke commented 1 year ago

@amalasyrafs - I just ran into the same issue today. It's due to a new release of the gradle plugin.

At least for local AS builds (using expo prebuild), I was able to tweak it

        dependencies {
            classpath 'com.bugsnag:bugsnag-android-gradle-plugin:[7.4.1]'
        }

instead of

        dependencies {
            classpath 'com.bugsnag:bugsnag-android-gradle-plugin:[7.3.0,)'
        }
thorbenprimke commented 1 year ago

The solution here it try to patch the config plugin locally so that EAS builds work as well.

thorbenprimke commented 1 year ago

Yea, I fixed the bugsnag gradle plug-in version to the latest before Gradle 8. Below the patch package. My build on EAS was successful. I feel like the config plug-in should be updated to protect against this breaking change. At least make it a configurable param to opt-in to use gradle 8. @lemnik what do you think?

diff --git a/node_modules/@bugsnag/plugin-expo-eas-sourcemaps/src/android.js b/node_modules/@bugsnag/plugin-expo-eas-sourcemaps/src/android.js
index 5f6279c..b23a06a 100644
--- a/node_modules/@bugsnag/plugin-expo-eas-sourcemaps/src/android.js
+++ b/node_modules/@bugsnag/plugin-expo-eas-sourcemaps/src/android.js
@@ -52,7 +52,7 @@ function injectDependencies (script) {
             mavenCentral()
         }
         dependencies {
-            classpath 'com.bugsnag:bugsnag-android-gradle-plugin:[7.3.0,)'
+            classpath 'com.bugsnag:bugsnag-android-gradle-plugin:[7.4.1]'
         }
     }
thorbenprimke commented 1 year ago

Nevermind - already fixed - https://github.com/bugsnag/bugsnag-expo/releases - strange that it didn't pull this in automatically since it's a patch version change.

amalasyrafs commented 1 year ago

Yeah it was fixed with the patch and I manage to create a build on Android again.

But your patch also helped a lot. Thanks @thorbenprimke . I was able to learn something new today.

luke-belton commented 1 year ago

Hi all - thanks for raising this with us, this was also discussed over on https://github.com/bugsnag/bugsnag-expo/issues/102. As mentioned in the thread above, this was caused by a beta release of our support for Android Gradle Plugin v8.

The fix has been released for all versions of Expo we currently maintain support for and ensures that this won't happen again for future v8 releases of the BugSnag Android Gradle Plugin. The issue also doesn't impact earlier versions of bugsnag-expo (i.e. v44 and below).

lucasklaassen commented 1 year ago

@luke-belton can you please publish 47.1.1 to npm?

imjoehaines commented 1 year ago

@lucasklaassen This only required an update to @bugsnag/plugin-expo-eas-sourcemaps where v47.1.1 is already on npm

@bugsnag/expo itself did not change, so there's no corresponding version on npm

So to update you only need to bump the version of @bugsnag/plugin-expo-eas-sourcemaps to v47.1.1