Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANDROID] Invalid value for 'projectId': "undefined" #1984

Closed
DefiOfThrones opened this issue Nov 12, 2020 · 4 comments · Fixed by #2051
Closed

[ANDROID] Invalid value for 'projectId': "undefined" #1984

DefiOfThrones opened this issue Nov 12, 2020 · 4 comments · Fixed by #2051
Labels
type-bug Something isn't working

Comments

@DefiOfThrones
Copy link

Hello I'm trying to start a debug build of Metamask Android version but I'm facing an issue and I don't find any way to contact the Metamask Community (if there is one).

Describe the bug
Here is the exact error : [Error: Invalid value for 'projectId': "undefined"]

I suspect the fact that I didn't fill the file .android.env with but I'm not sure.
export MM_FOX_CODE=
export MM_BRANCH_KEY_TEST=
export MM_BRANCH_KEY_LIVE=
export MM_MIXPANEL_TOKEN=

If the issue is related, where can I find the values ?

Screenshots
Screenshot from 2020-11-12 01-14-15

To Reproduce

  • Clone the git repository
  • yarn install
  • mv .android.env.example .android.env
  • cd android
  • yarn start:android

Expected behavior
The app starts correctly.

Smartphone (please complete the following information):

  • Pixel 2 API 29 ANdroid 10.0

to be added after bug submission by internal support / PM
Severity

  • How critical is the impact of this bug on a user?
  • Add stats if available on % of customers impacted
  • Is this visible to all users?
  • Is this tech debt?
@DefiOfThrones DefiOfThrones added the type-bug Something isn't working label Nov 12, 2020
@estebanmino
Copy link
Contributor

hey @DefiOfThrones can you follow this format in your js.env file? https://github.com/MetaMask/metamask-mobile/blob/develop/.js.env.example

@DefiOfThrones
Copy link
Author

Hello,

Thx you for your reply, now I have a similar error without undefined.

Screenshot from 2020-11-12 19-58-49

@stringcode86
Copy link
Contributor

stringcode86 commented Dec 5, 2020

I have encountered same issue. I did some digging. This started to occurring at this commit (infura v3 update) c74ce89. It started occurring because infura now throws exception if projectId is undefined or empty string. Quick and dirty workaround is in Engine.js

new NetworkController(
    {
	infuraProjectId: 'null', // instead of process.env.MM_INFURA_PROJECT_ID,

Root cause seems to be that .ios.env (and or .android.env, .js.env) variables are not being loaded

Logger.log(process.env);
>  [MetaMask DEBUG]: {"NODE_ENV": "development"}

even when changing .ios.env, .android.env, .js.env to

MM_FOX_CODE = 'null'
MM_BRANCH_KEY_TEST = 'null'
MM_BRANCH_KEY_LIVE = 'null'
MM_PUBNUB_SUB_KEY = 'null'
MM_PUBNUB_PUB_KEY = 'null'
MM_OPENSEA_KEY = 'null'
MM_INFURA_PROJECT_ID = 'null'

with or without export in front of the values. I ran yarn clean each time I change the values.

This is as far as I got, could not figure out why process.env does not load values from .ios.env, .android.env, .js.env

Update:

Upon further investigation I had to remove -- in (scrips/build.sh)

startWatcher() {
	source $JS_ENV_FILE
	if [ "$MODE" == "clean" ]; then
		watchman watch-del-all
		rm -rf $TMPDIR/react-*
		react-native start -- --reset-cache
	else
		react-native start
	fi
}

running yarn watch:clean then loads environment variables as expected. Only change needed is in .js.env export MM_INFURA_PROJECT_ID="null". This gets rid of the error at launch, but you will not be able to connect to actual networks.

  • I made a note of this in READ.me so that Non-Metamask users don't get derailed by this.
  • I changed default value to "null" in .js.env
  • Created pull request

stringcode86 added a commit to stringcode86/metamask-mobile that referenced this issue Dec 13, 2020
…id] [iOS]

ref: MetaMask#1984

Since infura 5.x.x empty string is invalid project id. Exception is thrown at launch `[Error: Invalid value for 'projectId': "undefined"] `. This leads to confusion for Non-Metamask users who try to get the project compiled. Changing default value to `MM_INFURA_PROJECT_ID="null"` will stop the exception. Restores behaviour to prior infura update.

 Non-Metamask users will still not be able to connect to any network. I make a note of this is README.md

(cherry picked from commit 4a3b463b936fb3d3f5ba02259a516db81a584016)
estebanmino pushed a commit that referenced this issue Dec 14, 2020
…id] [iOS] (#2051)

ref: #1984

Since infura 5.x.x empty string is invalid project id. Exception is thrown at launch `[Error: Invalid value for 'projectId': "undefined"] `. This leads to confusion for Non-Metamask users who try to get the project compiled. Changing default value to `MM_INFURA_PROJECT_ID="null"` will stop the exception. Restores behaviour to prior infura update.

 Non-Metamask users will still not be able to connect to any network. I make a note of this is README.md

(cherry picked from commit 4a3b463b936fb3d3f5ba02259a516db81a584016)
@0x00trust
Copy link

Hope this fix " No bulder URL present " for iOs
https://www.youtube.com/watch?v=eCs2GsWNkoo

cronny25 pushed a commit to cronny25/metamask-mobile that referenced this issue Jul 27, 2022
…id] [iOS] (#2051)

ref: MetaMask/metamask-mobile#1984

Since infura 5.x.x empty string is invalid project id. Exception is thrown at launch `[Error: Invalid value for 'projectId': "undefined"] `. This leads to confusion for Non-Metamask users who try to get the project compiled. Changing default value to `MM_INFURA_PROJECT_ID="null"` will stop the exception. Restores behaviour to prior infura update.

 Non-Metamask users will still not be able to connect to any network. I make a note of this is README.md

(cherry picked from commit 4a3b463b936fb3d3f5ba02259a516db81a584016)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Something isn't working
Projects
None yet
4 participants