MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.13k stars 1.1k forks source link

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

Closed DefiOfThrones closed 3 years ago

DefiOfThrones commented 3 years ago

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

Expected behavior The app starts correctly.

Smartphone (please complete the following information):


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

estebanmino commented 3 years ago

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

DefiOfThrones commented 3 years ago

Hello,

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

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

stringcode86 commented 3 years ago

I have encountered same issue. I did some digging. This started to occurring at this commit (infura v3 update) https://github.com/MetaMask/metamask-mobile/commit/c74ce8902c5e799a87555545949b447a9ab1b950. 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.

0x00trust commented 3 years ago

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