Metamask mobile browser not injecting window.ethereum in android

Viewed 59

I am running a simple code like below:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hello Bulma!</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
</head>
<body>
<section class="section">
    <div class="container">
        <h1 class="title">
            Hello World
        </h1>
        <p class="subtitle">
            <button class="btn btn-warning text-white" type="button" onclick="metamask()">
                Invest
                Here &rarr;
            </button>
        </p>
    </div>
</section>
<script>
    async function metamask() {
        const {ethereum} = window;
        var metamask = Boolean(ethereum && ethereum.isMetaMask);
        alert(typeof window.ethereum);
    }
</script>
</body>
</html>

but I get

typeof window.ethereum is undefined

It works fine in desktop metamask and iphone metamask dAPP. Doesnot work only in android metamask.

2 Answers

On android, press and hold metamask icon, go to app information, memory, "force stop". Try again. It worked for me after doing that. Also, take advantage to allow access to "files, media and camera".

Related