Toc
  1. Create Your Project
  2. Prerequire
  3. Run a build
  4. Config a profile to build APKs
  5. Install your build
  6. Pyhsical device
  7. Read Bild logs on Expo
  8. Fix Build Warings and Errors
  9. Push notifications overview
  10. Android FCM
  11. Setting up FCM
  12. Upload server credentials
Toc
0 results found
catzillaorz
Expo Build React Native Android APK package
Create Your Project
Prerequire
  1. Install expo cli
npm install -g eas-cli
  1. Login in
eas login
  1. Config eas
eas build:configure
Run a build
  • Build For Android Emulator/device or iOS Simulator
  • Build for app stores
Config a profile to build APKs

To generate an .apk, modify the eas.json by adding one of the following properties in a build profile:

  • developmentClient to true (default)
  • android.buildType to apk
  • android.gradleCommand to :app:assembleRelease, :app:assembleDebug or any other gradle command that produces .apk

Now you can run your build with the following command:

eas build -p android --profile preview
Install your build

tips: If you haven’t installed or run an Android Emulator before, follow the Android Studio emulator guide before proceeding.

  • Once your build is completed, the CLI will prompt you to automatically download and install it on the Android Emulator. When prompted, press Y to directly install it on the emulator.
  • In case you have multiple builds, you can also run the eas build:run command at any time to download a specific build and automatically install it on the Android Emulator:
eas build:run -p android
  • Running the latest build
eas build:run -p android --latest
Pyhsical device
  • Download directly to the device
    • Once your build is completed, copy the URL to the APK from the build details page or the link provided when eas build is done.
    • Send that URL to your device. Maybe by email? Up to you.
    • Open the URL on your device, install the APK and run it.
Read Bild logs on Expo

There you can see build history, make sure you have no warnings or Errors in buid process, like:

20231017154025-2023-10-17-15-40-26-

  • Errors

20231017154127-2023-10-17-15-41-28-

  • Otherwise your app will crash before runing on you Device
Fix Build Warings and Errors
  • Expo cli
npx expo install --fix
  • For example
Running "expo doctor"

Running 10 checks on your project...

✔ Check Expo config for common issues

✔ Check package.json for common issues

✔ Check dependencies for packages that should not be installed directly

✔ Check for common project setup issues

✔ Check npm/ yarn versions

✖ Check Expo config (app.json/ app.config.js) schema

✔ Check that packages match versions required by installed Expo SDK

✔ Check for legacy global CLI installed locally

✔ Check that native modules do not use incompatible support packages

✔ Check that native modules use compatible support package versions for installed Expo SDK

Detailed check results:

Error: Problem validating fields in app.json. Learn more: https://docs.expo.dev/workflow/configuration/

• Field: android/adaptiveIcon - should NOT have additional property 'jsEngine'.

One or more checks failed, indicating possible issues with the project.

Command "expo doctor" failed.
npx -y expo-doctor exited with non-zero code: 1
  • we can follow the logs suggesstions:

    1. : android/adaptiveIcon - should NOT have additional property ‘jsEngine’.
    2. Command “expo doctor” failed. npx -y expo-doctor exited with non-zero code: 1
  • these waring and error indecated that the building process is not running correct Although it build success

  • After fix issues, it should be like:

20231017155430-2023-10-17-15-54-30-

Push notifications overview

Follow the instructions should do the work!

Readme;

  • Key Step

  • Step 3: Get Credentials for development builds

  • Android

  • Setting up FCM

Android FCM

For Android and iOS, there are different requirements to set up your credentials.

For Android, you need to configure Firebase Cloud Messaging (FCM) to get your credentials and set up your Expo project. It is required for all Android apps using Expo SDK.

# FCM is not currently available for expo-notifications on iOS.
Setting up FCM
  • Follow these 7 steps Setting up FCM
  • Warning Proxy might need to allow google’s api & analysiz api so on, or you will failed at setting your config and enable services.
Upload server credentials

20231017160732-2023-10-17-16-07-33-

  1. paste token in your project
    • path: doerbasemobile/credentials/android/com.yourname.doerbasemobile

20231017160845-2023-10-17-16-08-45-

  • notice
# Expo Notifications only supports the Cloud Messaging API (Legacy) key at this time. This key is deprecated by Firebase. However, it will continue to work until June 30, 2024. We will provide information on migrating to the new v1 key in the future.
打赏
支付宝
微信
本文作者:catzillaorz
版权声明:本文首发于catzillaorz的博客,转载请注明出处!