jak
jak

Reputation: 121

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": [
      "**/*"
    ],
  }
}

Upvotes: 12

Views: 41406

Answers (10)

user25840938
user25840938

Reputation: 11

in my case I just had to delete the generated android folder

Upvotes: 0

Acid Coder
Acid Coder

Reputation: 2746

turn out eas respect gitignore!

I put app.json in gitignore because I generate my app.json

after removing it from gitignore, it is now aware of the package name

found my solution here: Your project must have a `package` set in the Expo config

Upvotes: 0

Andres Bustamante
Andres Bustamante

Reputation: 1

Ensure you have the same slug value in the app name package:

slug: 'myslug',
android: { package: 'com.mydomain.myslug' }

Upvotes: 0

nullSafety
nullSafety

Reputation: 65

after adding package name and versionCode in my app.json, I still got the same error

"android": {
  "package": "com.yourcompany.yourappname",
  "versionCode": 1
}

NOTE: I use Expo-CLI so I don't know if this works with Native CLI

I was able to fix the issue at hand and even fixed the issue with emulator throwing "pixel launcher keeps stopping" error.

in terminal, navigate to your projects directory and run the following commands:

> C:\project_dir> npx expo install [email protected] expo-dev-client@~1.3.0

> C:\project_dir> npx expo install expo-dev-client@~1.2.1

and then run the npm command to run the emulator

> C:\project_dir> npm run android

Upvotes: 0

Hershy Heilpern
Hershy Heilpern

Reputation: 54

//you have to update it in /android/app/build.gradle

Upvotes: 0

pkkwilliam
pkkwilliam

Reputation: 21

I know I might be late for the this, but I found the issue at least for myself was because the Expo create-react-native-app might build the app.json different from what it actually wanted (I might be wrong). I created a new expo app and compare the two. I found that the structure of the json changed and android should be nested inside expo like the following. BTW, this is my first answer in stackoverflow.

Correct:

{
 "expo": {
   "name": "youappname",
   "android": {
     "package": "com.web.app",
     "versionCode": 1
   }
 }
}

Upvotes: 2

jimbofreedman
jimbofreedman

Reputation: 412

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: {
        [...]
      }
    });
};

Upvotes: 6

rajarshi
rajarshi

Reputation: 131

In my case I had declared the "android" property at the top level within app.json. Rather, it should've been listed within the "expo" property as a sub-key. Duh!

Upvotes: 1

iamkdblue
iamkdblue

Reputation: 3632

This Worked for me, you can try this

{
  "expo": {
    "name": "kd-guess-number",
    "slug": "kd-guess-number",
    "sdkVersion": "37.0.0",
    "privacy": "public",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "description": "",

    "android": {
      "package": "com.yourcompany.yourappname",
      "versionCode": 1
    }

  }
}

You should add this at the end (See above my code for reference)

"android": {
      "package": "com.yourcompany.yourappname",
      "versionCode": 1
    }

Upvotes: 3

Kyle Laster
Kyle Laster

Reputation: 407

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

"android": {
  "package": "com.yourcompany.yourappname",
  "versionCode": 1
}

Upvotes: 24

Related Questions