Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Error "Your project must have an Android package set in app.json" despite that fact that I have an android package set in app.json

I'm building a react native project using expo. I'm on windows, so I enable WSL and install ubuntu from the microsoft store. Next I run expo build:android. I get the following error,

Your project must have an Android package set in app.json.

So I looked at expos tutorial page and it says to add,

"android": {
    "package": "com.yourcompany.yourappname"
}

I add that to the app.json file and I get the same error. I don't have the slightest idea as to why the error wont go away, because I've looked at the tutorial page and at my code, and I clearly have all the required fields.

This is the tutorial page I've been looking at : https://docs.expo.io/versions/latest/distribution/building-standalone-apps/

Anyways, this is my app.json file,

{
  "expo": {
    "name": "First React App",
    "slug": "FirstReactNativeApp",
    "privacy": "public",
    "sdkVersion": "35.0.0",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "ios": {
      "bundleIdentifier": "com.yourcompany.yourappname",
      "supportsTablet": true,
    },
    "android": {
      "package": "com.yourcompany.yourappname",
    },
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
  }
}
like image 907
jak Avatar asked Jan 26 '23 17:01

jak


2 Answers

I just arrived here after experiencing the same problem. Turns out my app.config.js wasn't passing on configuration from app.json.

I fixed it by changing:

export default {
  extra: {
    [...]
  },
};

to:

export default ({config}) => {
  return Object.assign(config,
    {
      extra: {
        [...]
      }
    });
};
like image 33
jimbofreedman Avatar answered Jan 31 '23 08:01

jimbofreedman


For anyone coming to this page, add the following to your app.json.

"android": {
  "package": "com.yourcompany.yourappname",
  "versionCode": 1
}
like image 197
Kyle Laster Avatar answered Jan 31 '23 07:01

Kyle Laster