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] Building from bundle #2703

Closed
ngreenwood6 opened this issue Sep 15, 2015 · 12 comments
Closed

[Android] Building from bundle #2703

ngreenwood6 opened this issue Sep 15, 2015 · 12 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ngreenwood6
Copy link

I have been working with react-native on iOS and found the bundling option in the AppDelegate.m file and it works great once you bundle it. However, I saw that Android was released today and I am not able to figure out how to do the same on Android. In iOS there is some code like this:

sourceURL = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

Is there an equivalent way to do this in Android or am I missing something? I just want to bundle it on the device so I can use it without being near my computer.

@ide ide added the Android label Sep 15, 2015
@sulliwane
Copy link

I'm also interested in the location of the AppDelegate.m equivalent for Android. Thanks.

@ide
Copy link
Contributor

ide commented Sep 15, 2015

MainActivity.java is the equivalent of the AppDelegate.

@kmagiera
Copy link
Contributor

@ngreenwood6 In MainActivity.java generated from template project there is a line setBundleAssetName("index.android.bundle") which basically makes java native code load js from android assets but with the current setup this will only happen if the file is present in assets.
Then you should be able to use react-native bundle to generate js bundle in the assets folder from which android build system should pick it up, but apparently this step doesn't seem to work cc @foghina

@sulliwane
Copy link

Ok. I was looking for how to download the index.android.bundle over http from the android device. I'll wait 0.12 then!

@brentvatne
Copy link
Collaborator

@sulliwane
Copy link

@brentvatne AWSOME, thanks a lot.

@kmagiera
Copy link
Contributor

As a workaround you may have try the following:

  1. Run packager in your project dir: react-native start
  2. Use curl to fetch bundle from server and place it in android asset dir: curl -k 'http://localhost:8081/index.android.bundle' > android/app/src/main/assets/index.android.bundle

@stephenparish
Copy link

In addition to @kmagiera's workaround, you may also want to pass in the query params to the packager for minifying / disabling dev:
http://localhost:8081/index.android.bundle?dev=false&minify=true&runModule=true

For the params available, see: https://github.com/facebook/react-native/blob/master/packager/README.md#pathtomodulenamemapbundle-query-params

@uinz
Copy link

uinz commented Sep 27, 2015

i got "index.android.bundle", and then what should i do to let it to be an apk file?

@stephenparish
Copy link

You can drop that into android/src/main/assets/.

@satya164
Copy link
Contributor

Closing as this feature is already in the stable releases.

@sujalBandhara
Copy link

sujalBandhara commented Jul 25, 2017

How can i change localhost to my own server IP? please help!!

Got ERROR

Couldn't connect to "ws://10.0.2.2:8081/message?device=Android%20SDK%20built%20for%20x86%20-%206.0%20-%20API%2023&app=com.bitfamilydemo&clientid=DevSupportManagerImpl", will silently retry

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants