Skip to content

Commit

Permalink
Fix crash on release versions after AGP 7.3 bump (#34797)
Browse files Browse the repository at this point in the history
Summary:
Release versions are currently broken on `main`. This happened once we bumped the AGP version to 7.3. It seems like that the path we used to use for assets has changed.

The app build successfully but it fails to start as it can't load the bundle.

This is also causing the hermes e2e test to fail: facebook/hermes#821

## Changelog

[Android] [Fixed] - Fix crash on release versions after AGP 7.3 bump

Pull Request resolved: #34797

Test Plan:
Tested this locally and it works fine with RN Tester (can run a release version of it).

Plus, inspecting the zip:

### Before

```
$ unzip -l packages/rn-tester/android/app/build/outputs/apk/hermes/release/app-hermes-arm64-v8a-release.apk | grep android.bundle
  1248608  01-01-1981 01:01   assets/mergeHermesReleaseAssets/RNTesterApp.android.bundle
```

### After

```
$ unzip -l packages/rn-tester/android/app/build/outputs/apk/hermes/release/app-hermes-arm64-v8a-release.apk | grep android.bundle
  1248608  01-01-1981 01:01   assets/RNTesterApp.android.bundle
```

Reviewed By: cipolleschi

Differential Revision: D39847369

Pulled By: cortinico

fbshipit-source-id: 0e21c0b6e58b49ac097c59223649b74b2879b5e5
  • Loading branch information
cortinico authored and facebook-github-bot committed Sep 27, 2022
1 parent 5933b6a commit 6125f1f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte
it.into(jsBundleDirConfigValue.get())
} else {
it.into(mergeAssetsTask.map { mergeFoldersTask -> mergeFoldersTask.outputDir.get() })
// Workaround for Android Gradle Plugin 7.1 asset directory
it.into("$buildDir/intermediates/assets/${variant.name}/merge${targetName}Assets")
// Workaround for Android Gradle Plugin 7.3 asset directory
it.into("$buildDir/intermediates/assets/${variant.name}")
}

it.dependsOn(mergeAssetsTask)
Expand Down
2 changes: 1 addition & 1 deletion react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ afterEvaluate {
into ("merged_assets/${variant.name}/out")

// Workaround for Android Gradle Plugin 7.1 asset directory
into("$buildDir/intermediates/assets/${variant.name}/merge${targetName}Assets")
into("$buildDir/intermediates/assets/${variant.name}")
}
}

Expand Down

0 comments on commit 6125f1f

Please sign in to comment.