Skip to content

Bundle not included in APK from within Android Studio #33018

@djibarian

Description

@djibarian

Description

Following on the issue #21132 I came to a slightly different problem. It seems that that issue refers to using react-native run-android, and that seems to finally work properly, i.e. the bundle is added to the APK properly.

But when building from Android Studio for release the bundle is still missing. I finally found the problem to be the same. build.gradle states that the default setting for jsBundleDirRelease is $buildDir/intermediates/assets/release, which is wrong. This must be changed to $buildDir/intermediates/assets/release/mergeReleaseAssets for Gradle to take the asset and add it to the APK.

So to avoid having to set jsBundleDirRelease to a proper value, it would be good to have the default value updated for this to work not only from the react-native run-android script, but also from Android Studio.

Version

0.66.4

Output of npx react-native info

System:
OS: macOS 12.2
CPU: (10) arm64 Apple M1 Pro
Memory: 195.25 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - /usr/local/bin/node
Yarn: 1.22.15 - /usr/local/bin/yarn
npm: 8.3.0 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
Android SDK:
API Levels: 26, 29, 30, 31, 32
Build Tools: 30.0.2, 30.0.3, 32.0.0
System Images: android-32 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8092744
Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: ^17.0.2 => 17.0.2
react-native: ^0.66.4 => 0.66.4
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Just try to build for release in Android Studio. Then inspect the APK in app/build/intermediates/apk and find that the assets folder is missing.

Snack, code example, screenshot, or link to a repository

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help Wanted :octocat:Issues ideal for external contributors.Platform: AndroidAndroid applications.Resolution: LockedThis issue was locked by the bot.Tech: Bundler 📦This issue is related to the bundler (Metro, Haul, etc) used.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions