Lexicon Version 1: 'Please connect to a network' issue after building an APK #32
-
Hi, My built standalone app was successful created. After installing the APK in my phone, I am unable to perform login functionality or any other functionality that was connected to API. |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments
-
Hello. Sorry to hear you're having trouble. Could you please fill out the issue template properly so we can help you? |
Beta Was this translation helpful? Give feedback.
-
I have built a standalone app using command
I have created a build and selected APK mode. I have installed the APK in my mobile and running it there. Steps to reproduce the behavior: I followed the exact steps mentioned in doc which were:
Expected behavior Desktop (please complete the following information):
Smartphone (please complete the following information):
I have a query, what do we need to built in frontend/ folder? |
Beta Was this translation helpful? Give feedback.
-
Thanks for filling out the issue template. Where did you host the Prose GraphQL API? Are you sure you configured the app to point at that URL as part of the build process? |
Beta Was this translation helpful? Give feedback.
-
These are the values I have been using: api/.env frontend/.env |
Beta Was this translation helpful? Give feedback.
-
If your You need to deploy the API somewhere accessible on the web, and configure the mobile app to point at that instead. You should read carefully through the Deploying Prose section of the documentation to make sure you understand it well. If you want a quick fix that is not a proper solution at all, you could temporarily use ngrok to expose the API running on your development machine to the web—just to get a working example on your mobile device. |
Beta Was this translation helpful? Give feedback.
-
Okay, I have pointed my deployment URL to the MOBILE_PROSE_HOST. After 10mins I realized that my metro bundler was already running in another cmd. When I stopped it, the fresh APK stopped working as well. |
Beta Was this translation helpful? Give feedback.
-
I created another APK after closing every CMD where my metro bundler was running. It is working just like it was in expo go where I had to run It seems it is somehow linked. What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
-
What did you deploy the API with / where is it deployed? Are you sure you're actually running the APK on your mobile device? And not the app that Expo Go produces to help you develop? How specifically are you loading the APK onto your device? |
Beta Was this translation helpful? Give feedback.
-
What did you deploy the API with / where is it deployed?
Are you sure you're actually running the APK on your mobile device? And not the app that Expo Go produces to help you develop?
How specifically are you loading the APK onto your device?
|
Beta Was this translation helpful? Give feedback.
-
I was able to follow the steps in https://docs.expo.dev/archive/classic-updates/building-standalone-apps and produce a build that is independent of any running metro bundler (I had two running on my machine and took them both down before trying). So I don't see any indicators that following the steps to build an APK and side load it with By the way, something that wasn't really clarified—what specifically do you mean by "the fresh APK stopped working as well"? Something can stop working in a lot of ways, so it would be helpful to know what you expected to happen versus what actually happened. You should sanity check every step that you took, because it sounds a lot like you are still interacting with the Expo Go app. I would also recommend doing the trigger action that causes the Expo Go app's menu to appear (holding down 3 fingers on the screen / shaking the device). If the Expo menu appears, you are definitely not running your APK. Last, I also noticed that my built APK does not have an icon because I did not configure one, so it was easy for me to differentiate it from any other Lexicon app that might be running on my Android device. Any indicators that would help to sanity check which app you're actually running might help to diagnose the problem. |
Beta Was this translation helpful? Give feedback.
-
By the 'fresh APK' I meant, I created another one after taking down my cmd where my metro bundler was running. I am following the exact steps mentioned in your document. Do I have to add anything else in .env of frontend? Screenshots: In the following image, you can see that there is an individual app where I have replaced 'Lexicon' with 'Forums'. I am running this one. It works fine only when the metro bundler is running on my machine. The following image shows that my Expo Go also does contain 2 projects, one is lexicon where I am modifying the code and the other one is my build (Forums), but I am not using it from here. I am running the one mentioned in 1st image. |
Beta Was this translation helpful? Give feedback.
-
I wasn't asking what you meant by fresh APK, I was asking what you meant by "stops working"—you haven't given any info on what the specific problem is you're encountering, other than saying some unspecified issue occurs when you stop running Metro. Did you try activating the Expo menu? Also, as I said, change the icon of your APK so you can be sure you are running the right app, don't use Expo Go in any way. You could even uninstall it and all "Forums" apps from your device before side loading the APK again. There have been quite a few suggestions here for how to debug the issues, rule out certain possibilities, and narrow in on what is going wrong. Also, if you've specified |
Beta Was this translation helpful? Give feedback.
-
By this I meant, the API is unable to get connected with the app, this api link is working fine in postman and otherwise but it seems like only the frontend part is working and not the backend in APK.
Yes I did, No debugging menu was activated. Actually, I was sure I am running my APK and not Expo Go. So, right now as per your suggestions, I have uninstalled Expo Go and modified .env file in frontend. (Now the file only contains MOBILE_PROSE_HOST value). BUILD RESPONSE √ Build finished. Successfully built standalone app: https://expo.dev/artifacts/a32de1fd-54bd-487a-8beb-7795a788a7cc SCREENSHOT FOR WHAT IS EXPECTED |
Beta Was this translation helpful? Give feedback.
-
Ok, there we go, thanks for providing details. Now I have some sense that this could be related to Lexicon. Try hosting the API at the root of the domain with no path / endpoint. For example, it would be at https://api.websitetoolbox.com, with no /qa1 etc after it. |
Beta Was this translation helpful? Give feedback.
-
Actually, I cannot make changes to the hosting Urls. These endpoints are provided by the company I'm working for. |
Beta Was this translation helpful? Give feedback.
-
I'm unable to reproduce your issue about metro somehow being coupled to a built APK. Something just isn't adding up there. It may be useful to host the API at the root to verify that it is not causing an issue. However, considering that you said you have only specified You could also use some network analysis tools on Android, like HTTP Toolkit, to inspect what the specific URL is that your built APK is trying to contact, and verify whether or not that is what you expect. Lastly, you'd need to verify that your host is actually online and reachable on the open internet. When I visited that URL, I encountered an error with some JSON that was sent back. It was not the GraphQL playground as would be expected. For now, I'm closing this issue until we have a minimal reproducible example with Lexicon. |
Beta Was this translation helpful? Give feedback.
-
"Please connect to a network" issues that are encountered after building your app often stem from misconfigured During development, there are more moving pieces to ensure that the Expo Go app on a mobile device is able to reach the development server running on the same network. In production, it is much simpler. The URL is simply And |
Beta Was this translation helpful? Give feedback.
"Please connect to a network" issues that are encountered after building your app often stem from misconfigured
.env
files, or the GraphQL API host not being online / reachable.During development, there are more moving pieces to ensure that the Expo Go app on a mobile device is able to reach the development server running on the same network.
In production, it is much simpler.
The URL is simply
MOBILE_PROSE_HOST
+MOBILE_PROSE_PORT
.And
MOBILE_PROSE_PORT
can often be omitted, since the desired target will often just be something likehttps://prose.mysite.com
. Because thehttps://
is already specified, there is typically no need to include a port number as well, although this of course va…