Skip to content

[Android] Building release APK with react-native bundle #2743

Closed
@mkonicek

Description

@mkonicek
Contributor

See #2703, looks like running react-native bundle and building with Gradle doesn't include the bundle in the APK.

Can you please document how to build release versions of Android apps? Should we release the Gradle plugin? Looks like react-native bundle is sufficient at this point. cc @kmagiera

Activity

changed the title [-][Android] `react-native bundle` to build a release APK[/-] [+][Android] Building release APK with `react-native bundle`[/+] on Sep 16, 2015
mkonicek

mkonicek commented on Sep 16, 2015

@mkonicek
ContributorAuthor

I think we need a separate guide on building release versions of apps. "Using offline bundle" is only documented inside "Running On Device (iOS)" right now.

flipace

flipace commented on Sep 16, 2015

@flipace
Contributor

Yes, that'd be great. I could only find a short block of information about this topic on the Debugging page in the documentation (disabling developer mode for the app. And it doesn't include any information about the bundle command)

cosmith

cosmith commented on Sep 16, 2015

@cosmith
Contributor

+1 on the documentation. Also see #2712

krizpoon

krizpoon commented on Sep 16, 2015

@krizpoon

This works for me:

  1. cd to the project directory
  2. Start the react-native packager if not started
  3. Download the bundle to the asset folder:
    curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
hswolff

hswolff commented on Sep 24, 2015

@hswolff
Contributor

Messed around with this for a while...seems like the only way (as of my writing this) to create a bundle for Android is to use the method that @krizpoon outlined above.

I tried:

react-native bundle --url src/index.android.js --out android/app/src/main/assets/index.android.bundle --root src

However it seems like the packager is excluding *.android.* files and throws the following error, despite /Users/hswolff/Sites/chartbeat/mobile_app/src/index.android.js existing:

➜  ~/Sites/chartbeat/mobile_app git:(phoenix) ✗ react-native bundle --url src/index.android.js --out android/app/src/main/assets/index.android.bundle --root src
Building package...

/Users/hswolff/Sites/chartbeat/mobile_app/node_modules/react-native/node_modules/promise/lib/done.js:10
      throw err;
      ^
NotFoundError: Cannot find entry file src/index.android.js in any of the roots: ["/Users/hswolff/Sites/chartbeat/mobile_app","/Users/hswolff/Sites/chartbeat/mobile_app/src"]
    at DependencyGraph._getAbsolutePath (/Users/hswolff/Sites/chartbeat/mobile_app/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js:186:11)
    at /Users/hswolff/Sites/chartbeat/mobile_app/node_modules/react-native/packager/react-packager/src/DependencyResolver/DependencyGraph/index.js:141:28
    at tryCallOne (/Users/hswolff/Sites/chartbeat/mobile_app/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/hswolff/Sites/chartbeat/mobile_app/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/hswolff/Sites/chartbeat/mobile_app/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:407:9)
    at process._tickCallback (node.js:336:13)

Even trying to do something clever like this:

react-native bundle --root src --url index.android.bundle?platform\=android\&dev=

Also throws the same error.

I imagine this will be looked at once the packager is in its own repo. For now I'm using the above outlined method.

javamonn

javamonn commented on Sep 30, 2015

@javamonn

@hswolff This is due to the hardcoded blacklist param that results in the index.android.js getting ignored. Looks like this has been fixed on 0.12-stable.

marty-wang

marty-wang commented on Oct 3, 2015

@marty-wang

can someone document the complete steps, from bundling all the way to installing the release version apk to device?

marty-wang

marty-wang commented on Oct 3, 2015

@marty-wang

I put together my steps here. Hopefully it will save people some time.

https://gist.github.com/marty-wang/5a71e9d0a6a2c6d6263c

jguffey

jguffey commented on Oct 6, 2015

@jguffey

+1

syarul

syarul commented on Oct 6, 2015

@syarul

+1

satya164

satya164 commented on Oct 7, 2015

@satya164
Contributor

I have a pull request open here - #3061

kkganesan

kkganesan commented on Oct 11, 2015

@kkganesan

@marty-wang +1 for gist

37 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @fab1an@kkganesan@brentvatne@jguffey@hswolff

      Issue actions

        [Android] Building release APK with `react-native bundle` · Issue #2743 · facebook/react-native