diff --git a/CHANGELOG.md b/CHANGELOG.md index b050ce8c4..b514e63da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ - Drop non-error objects reported as crashes since they don't have a stack trace ([#1279](https://github.com/Instabug/Instabug-React-Native/pull/1279)). - Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)). +### Fixed + +- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)). + ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) ### Added diff --git a/android/sourcemaps.gradle b/android/sourcemaps.gradle index 37875e070..68004228a 100644 --- a/android/sourcemaps.gradle +++ b/android/sourcemaps.gradle @@ -38,13 +38,7 @@ Task createUploadSourcemapsTask(String flavor) { try { def appProject = project(':app') def appDir = appProject.projectDir - def flavorPath = flavor + (flavor.empty ? '' : '/') - def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}release/index.android.bundle.map" - def sourceMapFile = new File(appDir, sourceMapDest) - - if (!sourceMapFile.exists()) { - throw new InvalidUserDataException("Unable to find source map file at: ${sourceMapFile.absolutePath}") - } + def sourceMapFile = getSourceMapFile(appDir, flavor) def jsProjectDir = rootDir.parentFile def instabugDir = new File(['node', '-p', 'require.resolve("instabug-reactnative/package.json")'].execute(null, rootDir).text.trim()).getParentFile() @@ -80,6 +74,32 @@ Task createUploadSourcemapsTask(String flavor) { return provider.get() } +File getSourceMapFile(File appDir, String flavor) { + def defaultFlavorPath = flavor.empty ? 'release' : "${flavor}Release" + def defaultSourceMapDest = "build/generated/sourcemaps/react/${defaultFlavorPath}/index.android.bundle.map" + def defaultSourceMapFile = new File(appDir, defaultSourceMapDest) + + if (defaultSourceMapFile.exists()) { + return defaultSourceMapFile + } + + if (flavor.empty) { + throw new InvalidUserDataException("Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.") + } + + def fallbackSourceMapDest = "build/generated/sourcemaps/react/${flavor}/release/index.android.bundle.map" + def fallbackSourceMapFile = new File(appDir, fallbackSourceMapDest) + + project.logger.info "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" + + "Falling back to ${fallbackSourceMapFile.absolutePath}." + + if (!fallbackSourceMapFile.exists()) { + throw new InvalidUserDataException("Unable to find source map file at: ${fallbackSourceMapFile.absolutePath} either.") + } + + return fallbackSourceMapFile +} + boolean isUploadSourcemapsEnabled() { def envValue = System.getenv('INSTABUG_SOURCEMAPS_UPLOAD_DISABLE')?.toBoolean() def defaultValue = true