callstack / super-app-showcase

Monorepository template for super app development with React Native and Re.Pack
MIT License
382 stars 63 forks source link

How can I build an .apk from the host app? #34

Closed abhay-keyvalue closed 1 year ago

abhay-keyvalue commented 1 year ago

I tryied to build an .apk using assembleRelease in the host app but it crashes when I open in my android device. On simulator, dev works fine

jbroma commented 1 year ago

Hi @abhay-keyvalue, thanks for trying out our template.

Could please provide me with more details (ideally some adb logcat logs) so we can help you solve the issues?

Out of the box, I've noticed that the build for android fails because of: > SigningConfig "release" is missing required property "storeFile". This is expected as we didn't upload the storefile for the release variant. You can modify packages/host/android/app/build.gradle to use SigningConfig.debug for the prod-ready apk.

Following this change, the app builds fine for me and displays Failed to load AuthProvider which is also kind of expected as we haven't provided the changes necessary to accomodate prod-ready catalog-server that will resolve the requests for federated modules (but we are actively working on that and will show that soon!).

akunal1 commented 1 year ago

I am also facing same kind of issue with release build apk. Here are the steps :

  1. opened Android folder of host app in android studio
  2. created a release apk.
  3. Installed that on a physical device
  4. when I am opening it I am getting an error on the screen "Failed to Load Auth Provider".

I believe when I am building the app it is not including other independent app's bundle into the host app. Could you please help me here with the correct steps ?. @jbroma

Thanks in Advance 🙏🏼

RafikiTiki commented 1 year ago

@akunal1 As mentioned in the comment above:

Following this change, the app builds fine for me and displays Failed to load AuthProvider which is also kind of expected as we haven't provided the changes necessary to accomodate prod-ready catalog-server that will resolve the requests for federated modules (but we are actively working on that and will show that soon!).

In Module Federation architecture, the other independent app's bundles (mini-apps) are not included in the Host App. They are rather dynamically pulled off the internet. While in the development mode, you have a Catalog Server running locally on your machine, and it is used to feed the information about where these bundles are stored to the ScriptManager, in Release/Production you should point to a publicly available instance of the Catalog Server. This is not something we support now in the Super App Showcase as it's more of an example and is not configured to be deployed in App Stores out-of-the-box. It is, however, something that we'd like to support in the future and we're actively working on it :)

Thangtn93 commented 1 year ago

I plan to use this example for a new project but example not configured to be deployed in App Stores is big problem Is there another way for this?

akunal1 commented 1 year ago

I tried deploying a release signed bundle in s3-Bucket and tried accessing that from host app . But it said that the bundle is invalid. I must be doing something wrong but have no clues ..

const resolveURL = Federated.createURLResolver({
    containers: {
      MiniApp: 'www.link-to-bundle/filename',
    },
  });
jbroma commented 1 year ago

I tried deploying a release signed bundle in s3-Bucket and tried accessing that from host app . But it said that the bundle is invalid. I must be doing something wrong but have no clues ..

const resolveURL = Federated.createURLResolver({
   containers: {
     MiniApp: 'www.link-to-bundle/filename',
   },
 });

You need to upload all the files produced by webpack inside outputs/<platform>/remotes. Then you need to make sure that the URL for the MiniApp in the createURLResolver has a format of https://link-to-bundle/path/[name][ext].

The container URLs are a blueprint - ScriptManager will try to resolve to a final URL depending on the bundle needed. First time the MiniApp is loaded it's going to look for https://link-to-bundle/path/MiniApp.container.bundle.

Thangtn93 commented 1 year ago

Can I create a local environment for these packages?

image
jbroma commented 1 year ago

Can I create a local environment for these packages? image

Could you please clarify what you mean and what you are trying to achieve?

If you would like to serve these packages locally, then all you have to do is just run yarn start from the root of the monorepo - this will launch 6 development servers (5 for mini-apps and 1 for host) that will serve all of these packages and they will be available for the host app to consume.

Thangtn93 commented 1 year ago

Can I create a local environment for these packages? image

Could you please clarify what you mean and what you are trying to achieve?

If you would like to serve these packages locally, then all you have to do is just run yarn start from the root of the monorepo - this will launch 6 development servers (5 for mini-apps and 1 for host) that will serve all of these packages and they will be available for the host app to consume. @jbroma sorry i'm having the problem [Failed to load AuthProvider ] deployed in App Stores and ChPlay I don't want to upload bundle auth to S3. I'm looking for a way to load offline bundle . It looks like this https://stackoverflow.com/questions/48209829/cannot-create-offline-bundle-for-react-native-ios

jbroma commented 1 year ago

@Thangtn93 I'm afraid at this moment it's not possible to include bundle to be consumed offline like that. I'll will look into it when I get the chance. The only other workaround that comes to my mind is to include the auth package at build time by simply importing the components needed from the auth package.