Android build fail when if productFlavors configurated
retyui opened this issue ยท 12 comments
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 uploadSourcemapsExpected 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
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-12305it doesn't work
-
uploadSourcemapsassigned only for first taskReleaseJsAndAssetsand never invoked
because assigned tobundleProdReleaseJsAndAssets
but I built stagingbundleStagingReleaseJsAndAssets -
also
sourceMapDestis incorrect:
def sourceMapDest = 'build/generated/sourcemaps/react/release/index.android.bundle.map'
// build/generated/sourcemaps/react/staging/release/index.android.bundle.map@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-12305Please test it and let us know if it fixes your issue so we can proceed with merging it or investigating it further.
@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
@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.
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
Can you use the same why how it was done on iOS? (instead of npx )
node $instabug_dir/bin/index.js upload-sourcemaps
see: #978
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.
@retyui This issue is now fixed in v11.12.0, please update to the latest version instead of using the snapshot ๐๐ผ
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!
@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!