callstack / super-app-example

This repository presents a compact super-app example from Callstack's blog, illustrating the use of a monorepo structure together with Re.Pack and Module Federation.
MIT License
30 stars 18 forks source link

Release Android app is crashing #1

Closed akunal1 closed 1 year ago

akunal1 commented 1 year ago

Steps to reproduce.

  1. Open host android folder in Android studio
  2. Build the android app in release mode
  3. install the .apk in physical device
  4. open the app.
  5. host App is opening as expected
  6. try to access mini app from host app
  7. app is crashing

I just wanted to know , If I am missing out any steps to build the prod app or this is not the correct way to it .

Thanks in Advance.

jbroma commented 1 year ago

Hey @akunal1,

creating a release variant of the app isn't fully implemented on the finished branch. I've created a separate branch called release where I've introduced some modifications to make it possible. Here's what you need to do to run the release variant on Android emulator:

  1. Create release bundles of the mini-apps for both platforms inside packages/mini-app. The output of this command will be inside of the packages/mini-app/build: yarn bundle
  2. Host the bundles so they are exposed to the host-app: python3 -m http.server 11000 --directory build/outputs/
  3. Build & run the app via Android Studio in release variant
  4. After the emulator is running, please remember to expose the necessary port to the emulator (without this step the app will crash as it will result it Network Error): adb reverse tcp:11000 tcp:11000

If you want to launch the release variant on your phone you will have to host the bundles on a publicly accessible server. You will also have to modify index.js inside of packages/host-app. In there, please adjust the address for the production bundles.

Modifications introduced to make it possible:

  1. Upgrade to Re.Pack to 3.2.0 which fixes an issue with creating production bundles
  2. Enable cleartext traffic for both android & iOS (for the sake of simplicity, this is not recommended for production apps)

If you want to launch the release variant on the iOS you will also have to:

  1. Reinstall pods as Re.Pack 3.2.0 introduced new pod dependencies
  2. Edit scheme so it runs in release variant (Product->Scheme->Edit Scheme->Run->Build Configuration: Release)
  3. Modify React-Codegen deployment target to iOS 12.4 inside of Xcode (this bug was fixed in RN 0.71.6)

Please let me know whether you were able to run the app in release successfully.

jbroma commented 1 year ago

Closing this issue since solution was provided.