Hi,
I'm trying to use CodePush for an Android app, and I can't get it working. Is there something wrong ?
Command to bundle the app
$ react-native bundle --platform android --bundle-output ./debug/main.bundle --entry-file index.android.js --assets-dest ./debug --dev false
bundle: Created ReactPackager
bundle: start
[14:20:48] <START> Whole Program Optimisations
[14:21:11] <END> Whole Program Optimisations (22894ms)
[14:21:11] <START> minify
[14:21:22] <END> minify (11652ms)
bundle: finish
bundle: Writing bundle output to: ./debug/main.bundle
bundle: Closing client
bundle: Copying 12 asset files
bundle: Done writing bundle output
bundle: Done copying assets
The file main.bundle is generated in the ./debug folder along with a folder drawable-mdpi containing images.
Command to upload the new version
$ code-push release zen-fifa ./debug 1.2.0
Upload progress:[==================================================] 100% 0.0s
Successfully released an update containing the "./debug" directory to the "Staging" deployment of the "zen-fifa" app.
Code in index.android.js
import codePush from 'react-native-code-push';
...
componentDidMount(){
codePush.sync({ updateDialog: true, installMode: codePush.InstallMode.IMMEDIATE });
}
...
And I always get this exception while trying to update on device:
03-23 14:11:44.396 5078 5094 W System.err: com.microsoft.codepush.react.CodePushInvalidUpdateException: Update is invalid - no files with extension .bundle, .js or .jsbundle were found in the update package.
03-23 14:11:44.396 5078 5094 W System.err: at com.microsoft.codepush.react.CodePushPackage.downloadPackage(CodePushPackage.java:249)
03-23 14:11:44.396 5078 5094 W System.err: at com.microsoft.codepush.react.CodePush$CodePushNativeModule$1.doInBackground(CodePush.java:362)
03-23 14:11:44.396 5078 5094 W System.err: at com.microsoft.codepush.react.CodePush$CodePushNativeModule$1.doInBackground(CodePush.java:356)
If I try to upload the .bundle file directly, update works but the app can't acces images.
Thanks !
Hi, mbernardeau.
In MainActivity.java where you call codePush.getBundleUrl(...) what bundle name do you pass? In your case I think it should be "main.bundle".
codePush.getBundleUrl("main.bundle")
Thanks,
Damon
@mbernadeau We used to look for the JS bundle (in a downloaded update) based on a few well-known extensions, but we recently changed that logic to expect the JS bundle you release to CodePush to use the exact same name that was shipped with the binary. Therefore, as @dtivel mentioned, if you're calling getBundleUrl("index.android.bundle") in your MainActivity.java file, you just need to call the JS bundle file "index.android.bundle" when you generate it using the React Native CLI.
I'm glad you reported this issue, since it helps us see that we clearly didn't update the error message when we changed the JS bundle locator logic :) I can send out a PR to fix that, but in the meantime, you should be able to get unblocked by following @dtivel's suggestion.
Also, we just recently shipped an update to the CLI that includes a "release-react" command that simplifies this whole process, and may be worth checking out. Thanks!
@dtivel @lostintangent Thanks a lot, it works perfectly now !
I guess the error message was just a bit misleading.
Anyway great work :)
Totally agreed that the error message is horrible :) I'll use this bug to track the work to fix it so that no one else hits this same problem.
Thanks so much for reporting it and confirming the suggested workaround.
Fixed this via #262. Thanks for the feedback and let us know if you hit anything else.
I encountered the modified error message. Not sure what went wrong. Here is my code
CLI:
*_Command: *_code-push release-react app_name android
Running "react-native bundle" command:
node node_modules/react-native/local-cli/cli.js bundle --assets-dest /var/folders/t3/dlvzzrc50k11spnvz0h613_00000gn/T/CodePush --bundle-output /var/folders/t3/dlvzzrc50k11spnvz0h613_00000gn/T/CodePush/index.android.bundle --dev false --entry-file index.android.js --platform android
bundle: Created ReactPackager
bundle: start
bundle: finish
bundle: Writing bundle output to: /var/folders/t3/dlvzzrc50k11spnvz0h613_00000gn/T/CodePush/index.android.bundle
bundle: Closing client
bundle: Copying 58 asset files
bundle: Done writing bundle output
bundle: Done copying assets
Releasing update contents to CodePush:
Upload progress:[==================================================] 100% 0.0s
Successfully released an update containing the "/var/folders/t3/dlvzzrc50k11spnvz0h613_00000gn/T/CodePush" directory to the "Staging" deployment of the "app_name" app.
Code in JS:
codePush.sync()
Code in Java:
new CodePush("staging key", this, BuildConfig.DEBUG),
Error message:
[CodePush] Update is invalid - A JS bundle file named "null" could not be found within the downloaded contents. Please check that you are releasing your CodePush updates using the exact same JS bundle file name that was shipped with your app's binary.
Environment:
RN 0.24 Android
Really appreciate your help!
@ACCTFORGH In Java, did follow all the Plugin Configuration steps? Specifically, did you override the getJSBundleFile() method in your ReactActivity to return CodePush.getBundleUrl()?
@geof90 Ah, I missed this step in the guide. Thanks for pointing it out!
Most helpful comment
@ACCTFORGH In Java, did follow all the Plugin Configuration steps? Specifically, did you override the
getJSBundleFile()method in yourReactActivityto returnCodePush.getBundleUrl()?