expo run:android not working

When I try to create an expo bare project with expo init and select the minimal one, and then I run the expo run:android command, my emulator starts but then it get’s stuck at

Starting a Gradle Daemon (subsequent builds will be faster)
<-------------> 0% INITIALIZING [3m 26s]

This goes on for 20+ minutes so I really think somethings wrong. Tried with administrator perks and gradle is in path. I really don’t know what else I can try

Kind regards
Jasper

Hi @aspyryan

In theory the following should work the same, but I believe the code paths are different, so there’s a chance it will give you a different result:

Try creating a new managed app:

expo init appname -t blank

and then run expo run:android, which will basically eject your app anyway.

1 Like

Hi, thanks for the answer!

I am trying this now but it get’s stuck at
| Config syncing, after the js dependancies get installed.
It’s been about 20 minutes now so yea don’t think it’s going anywhere.
1 hour later still going. Think it’s mainly this problem

Kind regards

What dependencies are you using?

Also, could I ask why you want to eject?

Hi, I’m trying to use this package in a react-native project and I’ve read I had to eject before the package could work so that’s why. And I don’t really know what you mean with dependencies because it’s not working for me with a plain new project

Kind regards

OK. That’s weird.

That information is out of date :slight_smile:

Expo has recently released EAS Build which allows you to use many packages in the Managed workflow where previously you would have had to eject to use them. Often they require a Config Plugin, though, and because EAS Build is only a few months old, many packages do not yet come with a config plugin built in. It’s possible for you to write your own config plugin.

But it looks like you’re in luck! According to the page you linked to, it already has a config plugin built in:

Prebuild Plugin

This package cannot be used in the “Expo Go” app because it requires custom native code.

After installing this npm package, add the config plugin to the plugins array of your app.json or app.config.js :

{ "expo": { "plugins": ["react-native-wifi-reborn"] } }

Next, rebuild your app as described in the “Adding custom native code” guide.

So it is not necessary to eject to use react-native-wifi-reborn. However, as it says in the instructions, you won’t be able to use Expo Go. You can, however, build a custom dev client, which is basically like a custom version of the Expo Go app.

I know the usual instructions for config plugins say that you should build your app as described in the “Adding custom native code” guide, but I’m really not sure why the Expo team recommends that, because that basically ejects your app and you need to manually clean up the changes if you don’t want that. I avoid running expo run:android. Instead I just build a custom dev client and then use that as I would have used the Expo Go app. And then of course build a production build if I want to submit it to the stores.

Running expo run:android definitely should not hang, so I’m not sure what’s happening when you try it, but maybe try:

eas build --platform android --profile preview

which should build an APK that you can install. Or:

eas build --platform android --profile development

to build a development client. Install expo-dev-client as a dependency before you build.

1 Like

Alright thank you for the response! I thought the problem was indeed with the package at first while it was not! The plugin indeed works fine and I got the package working.

This one did it! I was able to run the app with this and with the dev-client which is really helpfull!

Maybe you can still help me find the problem with expo since I might have spotted the bug in expo run:android. When I ran react-native run-android, it asked me for admin perks to do something with the firewall I think, but this never happend when using expo. So I’m thinking it has something to do with these perms and why it wouldn’t want to work.

EDIT
Well, now when I try to react-native run-android, it also won’t ask for that permission, so it will also not build on that. I really don’t know how or why this is happening.

And how would I go on and create myself a config plugin? If I read Config Plugins - Expo Documentation and if I read correctly I understand that I should create my own package or like edit it in the node-modules file which is not really correct I think?

I’m glad you got it working :slight_smile:

hmmm… the symptoms do seem like they might be caused by networking problems.

Firewalls are not usually configured to block outgoing traffic, so not sure how likely it is that your problems are caused by a firewall.

Are you by any chance behind a proxy server? If so you could try setting the https_proxy environment variable to specify the address of the proxy server for Expo to use:

export https_proxy=http://your.proxy.server:8080/

If you want to exclude certain things you can use the no_proxy environment variable:

export no_proxy="192.168.*,127.*,your-company.com"

I find the easiest is to look at existing config plugins to see if there’s something similar to what I want to do. e.g.:

So e.g. if I want to change AndroidManifest.xml, then I’ll check the docs and find withAndroidManifest. (I still don’t know how to use mods.android.manifest.)
Then I’ll run git grep withAndroidManifest in the expo/expo and expo/config-plugins repositories, and maybe search for it on GitHub. And I’ll check results for things that might be similar to what I’m trying to do.

Here are some Config Plugins I’ve written. I don’t claim to be an expert :slight_smile:
Note that the withReactNativeHce plugin should be marked as Dangerous because of the way it creates the aid_list.xml. I should probably rather take that out of the plugin and just copy the file into the right place using a post-install hook.

If you’re just writing a config plugin to use in your own app you do not need to create a package. You can just create a file that you refer to in app.json. e.g.: