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 release APK with react-native bundle
#2743
Comments
react-native bundle
to build a release APKreact-native bundle
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. |
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) |
+1 on the documentation. Also see #2712 |
This works for me:
|
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
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. |
@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. |
can someone document the complete steps, from bundling all the way to installing the release version apk to device? |
I put together my steps here. Hopefully it will save people some time. |
+1 |
1 similar comment
+1 |
I have a pull request open here - #3061 |
@marty-wang +1 for gist |
@kkganesan It's already on the documentation page - http://facebook.github.io/react-native/docs/signed-apk-android.html#content |
Closing this issue, looks like it's been solved by @satya164's PR |
Hi all, whenever I run the Has anyone else experienced this? I can't seem to get around it. I've posted on SO with no luck so far: http://stackoverflow.com/questions/33785803/error-generating-signed-apk |
cc @mikearmstrong001 ^ |
Just as an update, the only way so far that I can create a signed APK is by running the |
@scgough I have same question. Have you solved it? |
Hi there @shawnXiao - I can run the following to compile the package now (from the project folder in terminal):
|
You don't need to run any commands. The gradle script automatically bundles the script for you. |
I have tried all the guides and still can't generate a working apk, it always keeps crushing, seems like the bundle not deliveres to the apk |
Same here ? |
Same here, It works for the app debug on my device, but when I build a release, install on device and open it throws a "App stopped working". This started to happen from react-native 0.24 (It was working with 0.22) Should I create a new issue?, because this one is closed |
Same here, Gradle is not outputting the JS bundle file |
@philohelp There's no "./gradlew installRelease" task... (RN 0.26) |
@pjnovas same issue here, after upgrading to 0.22.2 from 18 - not sure if that's the same as your 0.22. Thought I'd add it here in case you did open another issue, as I'm at a loss of what to do. |
I'm using version
|
@neciu do you use the |
@fab1an the one given to me by |
but shouldn't that one build the bundle by itself without you manually having to do it? |
I have encountered a similar problem as @scgough described. In my case, it is Could not list contents of '/Users/me/React/myapp/node_modules/.bin/window-size'. The windows-size is a symbolic link point to '../window-size/cli.js', and this file disappeared, so I reinstalled the window-size package and the problem solved. |
@levinqdl o wow! I gonna test that this evening! |
Hi all - sorry I've not been active on this. Been on other projects. To summarise though, I can only create an Android APK using the method @neciu described. Not the end of the world but slightly more painful than iOS. It just feels a bit of a 'hacky' process. |
In my case ./gradlew assembleRelease
...
FAILURE: Build failed with an exception.
* What went wrong:
Could not list contents of '/Users/devpc/myproject/node_modules/.bin/window-size'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I simply had to remove that empty file |
@marty-wang : Your guide was awesome. Really helped a lot. |
A solution which worked for me was deleting node_modules, run 'npm install' on the project folder |
I tried the following: Generate APK (UNSIGNED) (Android)
But no .apk file created. I'm trying to generate an unsigned app, to install it on my own mobile. What did I miss? |
@Vadorequest the APK you seek should reside in |
@fab1an Thanks, I must have missed that in the doc. I tried to Finally, I just tried with the |
@Vadorequest You did not miss it, it's simply not in the docs. You can install the signed apk using |
@neciu do we have to run |
(in project directory run following commands)
|
I am creating release apk in react native using below commands. It works for me. react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ Mac Windows Open SDK -> Click on rebuild -> Fixed gradle build issue -> click on rebuild again -> generate signed apk. |
I was able to build for offline use without having to sign using @krishan-kumar-mourya instructions! The only problem is now I don't have my assets that were loaded as so Update |
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 @kmagieraThe text was updated successfully, but these errors were encountered: