Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Expo changing target Android API

Recently we build Android Apps using react expo and build signed APK using bellow command expo build:android -t apk or Android App Bundle expo build:android -t app-bundle

After we build signed APK, we tried to upload to Playstore and some error appears that wanted us to upgrade target API from 26 to 28. Have explored and reading several QA at SO and many of them are intended for React Native. How we can publish our APK to Play Store?

Here are app.json

{
  "expo": {
    "name": "***",
    "slug": "***",
    "privacy": "public",
    "sdkVersion": "32.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "1.2.3",
    "orientation": "portrait",
    "icon": "./assets/logo.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "enabled": true,
      "checkAutomatically": "ON_LOAD",
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "com.qreatiq.foodmart",
      "permissions": [
        "CAMERA"
      ],
      "googleServicesFile": "./google-services.json",
    },
  }
}

We've tried to check the documentation here and there are property for compileSDKVersion or related like native apps.

In Native app we can easily configure as bellow

compileSdkVersion 27
buildToolsVersion "27.0.3"
minSdkVersion 16
targetSdkVersion 27

How to do that at React Expo?

Update 1 after reading from developer.android.com

When you upload an APK, it needs to meet Google Play’s target API level requirements. Starting August 1, 2019, Google Play requires that new apps target at least Android 9.0 (API level 28), and that app updates target Android 9.0 from November 1, 2019. Until these dates, new apps and app updates must target at least Android 8.0 (API level 26).

Still doesn't have any idea for that things.

like image 421
Yohanim Avatar asked Aug 16 '19 08:08

Yohanim


People also ask

Is React Native better than Expo?

It helps you from the creation to distribution of your React Native apps. Remember, when you are coding in Expo, you still write React Native code. But with the support of the Expo CLI and Expo Client on your smartphone. It is better to use Expo CLI if you are new to app development.


1 Answers

Follow these steps:

  1. Close your Expo CLI server
  2. In app.json, change sdkVersion to "34.0.0"

  3. In package.json, change these dependencies:

    • react-native to "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz"
    • expo to "^34.0.3"
    • react to "16.8.3" — (this exact version)
    • react-navigation to "^3.11.1"
    • jest-expo to "^34.0.0" (if you use it)
    • sentry-expo to "~1.13.0" (if you use it)
  4. If you use react-navigation you should also run expo install react-native-gesture-handler react-native-reanimated

  5. Delete your project’s node_modules directory and run npm install again or use yarn

  6. Run expo start -c

After these steps, it should work.

Source: https://blog.expo.io/expo-sdk-34-is-now-available-4f7825239319

like image 108
Johnny Baptista Avatar answered Nov 15 '22 00:11

Johnny Baptista