Undefined "Constants.manifest.extra" on Android (genymotion)


#1

Hello,

I’m trying to use Constants.manifest.extra it works on iPhone but returns undefined on Android (genymotion)

Here is my app.json

{
  "expo": {
    "sdkVersion": "26.0.0",
    "extra" : {
      "apiUrl" : "http://192.168.1.102:8000/"
    }
  }
}

Js Code

import {Constants} from ‘expo’

import {Constants} from 'expo'


export const apiUrl = (path = '') => {

  alert(
    JSON.stringify(Constants.manifest.extra)
  )

}

package.json

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "jest-expo": "26.0.0",
    "react-native-scripts": "1.13.1",
    "react-test-renderer": "16.3.0-alpha.1"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "expo": "^26.0.0",
    "react": "16.3.0-alpha.1",
    "react-native": "^0.54.4",
    "react-navigation": "^1.5.10",
    "react-redux": "^5.0.7",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0"
  }
}

Any Ideas?
Thanks


#2

I couldn’t find anything on extras here is where the magic happens: https://github.com/expo/expo-sdk/blob/b67cd7e2d387e700b4ff5f03485cc95ca41d4617/src/Constants.js#L6-L15
Looks like things are a little different for android, have you tried using the manifest key?
Also (lmao) I don’t know if this works in prod but you could always try doing a little bit of this action:

const app = require("./app.json")

closed #3

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.