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

> Task :app:bundleReleaseJsAndAssets_SentryUpload ... FAILED #2309

Closed
hetmann opened this issue Jun 22, 2022 · 10 comments
Closed

> Task :app:bundleReleaseJsAndAssets_SentryUpload ... FAILED #2309

hetmann opened this issue Jun 22, 2022 · 10 comments

Comments

@hetmann
Copy link

hetmann commented Jun 22, 2022

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
"@sentry/react-native": "3.4.3",

Steps to Reproduce

  1. Building android using Fastlane
  2. Sentry integration is set to default using sentry-wizard
  3. Previously was working using this task > Task :app:[email protected]+2112328043_2112328043
  4. Nothing was changed in sentry integration but android using this task > Task :app:[email protected]+-2095294253_-2095294253 FAILED
  5. Notice the differences between task name with - sign and without it

Expected Result

Build without failing :)

Actual Result

I think somewhere the Android sentryUpload task is auto generating the id/number with a - sign. I double checked if we changed/updated something in the code base after the this task was failing and I confirm that there was no major update, only small UI updates.

wdyt @marandaneto

Screenshot 2022-06-22 at 16 31 34
Screenshot 2022-06-22 at 16 31 15

@marandaneto
Copy link
Contributor

@hetmann we use the versionCode or env. var. SENTRY_DIST in case you have defined it.

def defaultVersionCode = output.getVersionCode()
def versionCode = System.getenv("SENTRY_DIST") ?: defaultVersionCode

versionCode = currentVariant[2]

This is usually generated by your App's build script, e.g.
https://github.com/facebook/react-native/blob/80f73671495c4330ddf7e1db85a42c629a557ee2/template/android/app/build.gradle#L250-L255

Can you check in your file if this could lead to negative numbers?
We can likely abs the number but you can also likely fix it on your end, does that help?

@hetmann
Copy link
Author

hetmann commented Jun 22, 2022

@marandaneto thank you for your answer. I dig a bit and it kinda doesn't make sense

versionCode is generated by Fastlane using build_number = Time.new.to_i which is the unix timestamp and use it here

# update version code from build.gradle
increment_version_code(
  version_code: build_number,
  gradle_file_path: "./android/app/build.gradle"
)

So I had build_number set to 1655674737 but the the task would say Uploading sourcemaps for release [email protected]+2112328043 distribution 2112328043 so is kinda odd

Also android/app/build.gradle has this configs

splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk true  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    defaultConfig.versionCode * 1000 + versionCodes.get(abi)
        }

    }
}

@marandaneto marandaneto moved this from Needs Discussion to In Progress in Mobile & Cross Platform SDK Jun 23, 2022
@marandaneto marandaneto moved this from In Progress to Needs Review in Mobile & Cross Platform SDK Jun 23, 2022
@marandaneto
Copy link
Contributor

Not sure then, maybe Fastlane sets something to versionCode, we just read it.
I've calculated the absolute number, so it should avoid such cases.
#2313

@marandaneto
Copy link
Contributor

#2313

Repository owner moved this from Needs Review to Done in Mobile & Cross Platform SDK Jun 24, 2022
@hetmann
Copy link
Author

hetmann commented Jun 25, 2022

@marandaneto I'll try the new version and let you know the results.

@hetmann
Copy link
Author

hetmann commented Jun 25, 2022

@marandaneto I updated to "@sentry/react-native": "4.0.1" and the versionCode is set to 1656072137

[13:31:26]: The increment_version_code plugin will use gradle file at (./android/app/build.gradle)!
[13:31:26]:  -> line: (versionCode 1656072137)!
[13:31:26]: ☝️ Version code has been changed to 1656156647

but the sentry android versionCode is still -1700729253

[13:33:17]: ▸ > Task :app:[email protected]+-1700729253_-1700729253 FAILED
[13:33:17]: ▸ error: Found argument '-1' which wasn't expected, or isn't valid in this context
[13:33:17]: ▸ USAGE:
[13:33:17]: ▸ sentry-cli react-native gradle [OPTIONS] --bundle <PATH> --dist <DISTRIBUTION>... --release <RELEASE> --sourcemap <PATH>

Super strange ... I will dig up more to see whats going on.

@marandaneto
Copy link
Contributor

Its not released yet, Monday you test it again with 4.0.2

@hetmann
Copy link
Author

hetmann commented Jun 27, 2022

@marandaneto I just tried Sentry RN v4.0.2 and it seems is partial fixed but I got the same error:

Uploading sourcemaps for release [email protected]+1656332208 distribution 1656332208
...
> Task :app:[email protected]+-1525168254_1525168254 FAILED
error: Found argument '-1' which wasn't expected, or isn't valid in this context

If you notice there is - sign at the first versionCode but not on the second one after _ => @1.1.3+-1525168254_1525168254

Does this make any sense?

@qualitymanifest
Copy link

I had this same problem. I think the problem was that the versionCode specified in my build.gradle was high enough that when multiplied by 1000, it was higher than some maximum allowable integer (maybe google play's maximum of 2100000000?) so it would wrap around and become a negative number. Fixed it by lowering the number as low as it could be while still being higher than the last published version.

@dleavittpmc
Copy link

Commenting to say what fixed it for me.

I upgraded the version from 5.6.0 to 5.11.1, then ran a ./gradlew clean. I no longer hit this error and can build fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants