Saturday, 12 October 2019

react native build standalong android app

//cmd

npm install -g expo-cli
expo init AwesomeProject
cd AwesomeProject

//app.json

{
  "expo": {
    "name": "native2",
    "slug": "react-native2",
    "privacy": "public",
    "sdkVersion": "35.0.0",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "com.chuanshuoge.native1" //com.compnay.app
    }
  }
}

-------------------------
//cmd

C:\Users\bob\react-native2>expo build:android
Checking if there is a build in progress...


? Would you like to upload a keystore or have us generate one for you?
If you don't know what this means, let us handle it! :)
 false
Unable to find an existing Expo CLI instance for this directory, starting a new one...
Starting Metro Bundler on port 19001.
Tunnel ready.
Publishing to channel 'default'...
Building iOS bundle
Building Android bundle
Building JavaScript bundle [=====================================================================================] 100%Finished building JavaScript bundle in 23437ms.
Analyzing assets
Building JavaScript bundle [=====================================================================================] 100%Finished building JavaScript bundle in 20697ms.
Finished building JavaScript bundle in 7245ms.
Finished building JavaScript bundle in 4665ms.
Uploading assets
No assets changed, skipped.
Processing asset bundle patterns:
- C:\Users\bob\react-native2\**\*
Uploading JavaScript bundles
Published
Your URL is

https://exp.host/@chuanshuoge/react-native2

› Closing Expo server
› Stopping Metro bundler
Checking if this build already exists...

Build started, it may take a few minutes to complete.
You can check the queue length at https://expo.io/turtle-status

You can monitor the build at

 https://expo.io/builds/c7b4ddf8-6fb4-479e-92aa-1c0163965768

Waiting for build to complete. You can press Ctrl+C to exit.
√ Build finished.
Successfully built standalone app: https://expo.io/artifacts/54141cb8-b79f-40fb-9775-f4deadb03dff

//open link in browser will auto download .apk

------------------------------
drage and drop apk to android simulator will auto install

app works

reference:
https://docs.expo.io/versions/latest/distribution/building-standalone-apps/

3 comments: