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

Android build fail when if productFlavors configurated #974

Closed
retyui opened this issue Apr 28, 2023 · 12 comments · Fixed by #975
Closed

Android build fail when if productFlavors configurated #974

retyui opened this issue Apr 28, 2023 · 12 comments · Fixed by #975
Assignees

Comments

@retyui
Copy link
Contributor

retyui commented Apr 28, 2023

Steps to Reproduce the Problem

Add productFlavors prod & staging

try to clean build/assemble apk

./android/gradlew clear -p android

it will fail Cannot invoke method finalizedBy() on null object

more details:

// instabug-reactnative/android/sourcemaps.gradle

    def bundleTask = appProject.tasks.find {
        task -> task.name.endsWithIgnoreCase('bundleReleaseJsAndAssets')
    }

   bundleTask // null - 
   // ^^^ because when android has flavors task will be called:
   // - bundleProdReleaseJsAndAssets
   // - bundleStagingReleaseJsAndAssets

    bundleTask.finalizedBy uploadSourcemaps

Expected Behavior

no errors

Actual Behavior

FAILURE: Build failed with an exception.

* Where:
Script 'node_modules/instabug-reactnative/android/sourcemaps.gradle' line: 11

* What went wrong:
Cannot invoke method finalizedBy() on null object

Instabug integration code

no

SDK Version

the latest

React Native, iOS and Android Versions

android

Device Model

[Optional] Project That Reproduces the Issue

@a7medev
Copy link
Contributor

a7medev commented May 2, 2023

Hi @retyui! Thanks for reporting this issue and providing a very helpful description of the problem. We have been able to reproduce the issue from our side and created a PR with the fix (#975) and a snapshot that you can install using the command below:

npm install https://github.com/Instabug/Instabug-React-Native\#snapshot/11.10.0-MOB-12305

@a7medev a7medev closed this as completed May 2, 2023
@a7medev a7medev reopened this May 2, 2023
@retyui
Copy link
Contributor Author

retyui commented May 8, 2023

it doesn't work

  1. uploadSourcemaps assigned only for first task ReleaseJsAndAssets and never invoked
    because assigned to bundleProdReleaseJsAndAssets
    but I built staging bundleStagingReleaseJsAndAssets

  2. also sourceMapDest is incorrect:

def sourceMapDest = 'build/generated/sourcemaps/react/release/index.android.bundle.map'
                  // build/generated/sourcemaps/react/staging/release/index.android.bundle.map

@a7medev
Copy link
Contributor

a7medev commented May 9, 2023

@retyui Thanks again for testing it and letting us know that it's still failing. We created another PR with a possible fix for these problems (#978) and will update you with a snapshot once ready.

@a7medev a7medev self-assigned this May 9, 2023
@a7medev
Copy link
Contributor

a7medev commented May 10, 2023

@retyui Your snapshot is ready, you can install it using the same command as before:

npm install https://github.com/Instabug/Instabug-React-Native\#snapshot/11.10.0-MOB-12305

Please test it and let us know if it fixes your issue so we can proceed with merging it or investigating it further.

@retyui
Copy link
Contributor Author

retyui commented May 10, 2023

@a7medev did you tested it?

For me it fails:

> Task :app:bundleStagingReleaseJsAndAssets
info Writing bundle output to:, /Users/i/all_work/sp/src/react/packages/obt/mobile/android/app/build/generated/assets/react/staging/release/index.android.bundle
info Writing sourcemap output to:, /Users/i/all_work/sp/src/react/packages/obt/mobile/android/app/build/intermediates/sourcemaps/react/staging/release/index.android.bundle.packager.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 38 asset files
info Done copying assets

> Task :instabug-reactnative:uploadSourcemapsStaging
Failed to upload source map file.
Reason: Unable to find source map file at: /Users/i/all_work/sp/src/react/packages/obt/mobile/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map

@a7medev
Copy link
Contributor

a7medev commented May 10, 2023

@retyui Sorry for the inconvenience. It was due to a slight change I introduced after testing it. I did fix it now and it should work fine if you reinstall it with the same command. Please let us know if there are any further issues.

@retyui
Copy link
Contributor Author

retyui commented May 10, 2023

Now seems it's works !

but fail with the same error that I reported in another issue: #976

> Task :instabug-reactnative:uploadSourcemapsStaging
Environment variable `INSTABUG_APP_TOKEN` might have incorrect value, make sure this was intentional:
   Environment Value: 1234
   Default Value: null
npx: installed 53 in 5.354s
command not found: instabug
Failed to upload source map file.
Reason: Process 'command 'npx'' finished with non-zero exit value 1

@retyui
Copy link
Contributor Author

retyui commented May 10, 2023

Can you use the same why how it was done on iOS? (instead of npx )

https://github.com/Instabug/Instabug-React-Native/blob/a9c47e26c6eb6d9b0246c211c837a0ec7e77b46d/ios/sourcemaps.sh#LL32C1-L37C27

node $instabug_dir/bin/index.js upload-sourcemaps

see: #978

@stale
Copy link

stale bot commented May 18, 2023

This issue has been automatically marked as pending feedback because we need additional information to be able to investigate it further. It will be closed in 7 days if it remains inactive. Thank you for your contributions.

@a7medev
Copy link
Contributor

a7medev commented May 31, 2023

@retyui This issue is now fixed in v11.12.0, please update to the latest version instead of using the snapshot 🙏🏼

@xuanmai-agilityio
Copy link

Hi there, that's great when Instabug supports flavors for Android. But in my React Native app, the source map is generated on a little bit different folder.
build/generated/sourcemaps/react/stagingRelease/index.android.bundle.map instead of staging/release.
So the fix still failed to upload the source map.
Anyone know the reason and how can we fix that? Thanks in advance!

@xuanmai-agilityio
Copy link

@a7medev
And I also got an issue with the INSTABUG_APP_TOKEN, I set up Instabug for multiple envs so I move the key to the .env files and load it using react-native-config. And when uploading source map, it can not found the INSTABUG_APP_TOKEN in the JS code via find-token.sh.
Is there any way to set INSTABUG_APP_TOKEN as env variable when running sourcemaps.gradle.
Thanks!

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

Successfully merging a pull request may close this issue.

3 participants