Error: Problem validating fields in app.json. Learn https://docs.expo.dev/workflow/configuration/ • Field: android.permissions[4] - should be string

Viewed 851

I am using expo for my app and i randomly stated getting this error in my cli.This error doesn't stop the app from running. I searched around and haven't seen anyone with this error. Could it be due to the way my app.json/app.config file was setup? I do not want to remove the plugin sections because I need it. Thanks in advance

app.config.js

import "dotenv/config";

export default {
  expo: {
    plugins: [
      [
        "expo-image-picker",
        {
          photosPermission:
            "The app accesses your photos to let you share them with your friends.",
        },
      ],
      [
        "expo-media-library",
        {
          photosPermission: "Allow $(PRODUCT_NAME) to access your photos.",
          savePhotosPermission: "Allow $(PRODUCT_NAME) to save photos.",
          isAccessMediaLocationEnabled: true,
        },
      ],
      [
        "expo-camera",
        {
          /* Values passed to the plugin */
          locationWhenInUsePermission:
            "Allow $(PRODUCT_NAME) to access your location",
        },
      ],
    ],
    name: "Appname",
    slug: "Appnameslug",
    version: "1.0.0",
    orientation: "portrait",
    icon: "./assets/icon.png",
    splash: {
      image: "./assets/splash.png",
      resizeMode: "contain",
      backgroundColor: "#008080",
    },
    updates: {
      fallbackToCacheTimeout: 0,
    },
    assetBundlePatterns: ["**/*"],
    ios: {
      supportsTablet: true,
    },
    android: {
      adaptiveIcon: {
        foregroundImage: "./assets/adaptive-icon.png",
        backgroundColor: "#008080",
      },
    },
    web: {
      favicon: "./assets/favicon.png",
    },
    extra: {
      apiKey: process.env.API_KEY,
      authDomain: process.env.AUTH_DOMAIN,
      projectId: process.env.PROJECT_ID,
      dataBaseURL: process.env.DATABASE_URL,
      storageBucket: process.env.STORAGE_BUCKET,
      messagingSenderId: process.env.MESSAGING_SENDER_ID,
      appId: process.env.APP_ID,
      recaptchaKey: process.env.RECAPTCHA_KEY,
    },
  },
};

package.json

{
  "name": "appname",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo-google-fonts/inter": "^0.2.0",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/drawer": "^6.1.8",
    "@react-navigation/elements": "^1.2.1",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/stack": "^6.0.11",
    "axios": "^0.24.0",
    "dotenv": "^10.0.0",
    "expo": "~43.0.0",
    "expo-app-loading": "~1.2.1",
    "expo-application": "~4.0.0",
    "expo-camera": "~12.0.3",
    "expo-cellular": "~4.0.0",
    "expo-constants": "~12.1.3",
    "expo-device": "~4.0.3",
    "expo-image-picker": "~11.0.3",
    "expo-linear-gradient": "~10.0.3",
    "expo-localization": "~11.0.0",
    "expo-location": "~13.0.4",
    "expo-media-library": "~13.0.3",
    "expo-network": "~4.0.3",
    "expo-permissions": "~13.0.3",
    "expo-secure-store": "~11.0.3",
    "expo-status-bar": "~1.1.0",
    "firebase": "^9.5.0",
    "jwt-decode": "^3.1.2",
    "moment": "^2.29.1",
    "prop-types": "^15.7.2",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-android-open-settings": "^1.3.0",
    "react-native-animatable": "^1.3.3",
    "react-native-dropdownalert": "^4.3.0",
    "react-native-event-listeners": "^1.0.7",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-iphone-x-helper": "^1.3.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-maps": "0.28.1",
    "react-native-onboarding-swiper": "^1.1.4",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.8.0",
    "react-native-shimmer-placeholder": "^2.0.8",
    "react-native-star-rating": "^1.1.0",
    "react-native-swiper": "^1.6.0",
    "react-native-web": "0.17.1",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.4.0",
    "reselect": "^4.1.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}
2 Answers

I had the exact same issue and stumbled upon this while searching for solutions. After some digging, it turns out you have to change all of the plugin permission values to strings.

...
      [
        "expo-media-library",
        {
          photosPermission: "Allow $(PRODUCT_NAME) to access your photos.",
          savePhotosPermission: "Allow $(PRODUCT_NAME) to save photos.",
          isAccessMediaLocationEnabled: "true",
        },
      ],
...

Change

isAccessMediaLocationEnabled: true

to

isAccessMediaLocationEnabled: "true"

I encounter this recently, and the solution above is not the greatest.

Change isAccessMediaLocationEnabled from boolean true to string "true" may let the console not complaining about android.permissions[4] - should be string. But on the other hand the plugins of "expo-media-library" will set isAccessMediaLocationEnabled to false by default. Because it doesn't recognized string value.

So what I have done is to upgrade to expo sdk 45. And everything is solved.

Related