You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "benerogerio (via GitHub)" <gi...@apache.org> on 2025/03/21 18:35:09 UTC
[I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
benerogerio opened a new issue, #1791:
URL: https://github.com/apache/cordova-android/issues/1791
# Bug Report
## Problem
With a new release, in production, i'm getting an error when i try to start the app
### What is expected to happen?
Must work on prod.
### What does actually happen?
On dev env, it works with no problems, but when a up a new build release to the store, the app doesnt work, and show the following error message:
```html
Application Error
net::ERR_CONNECTION_REFUSED
(https://localhost/index.html)
```
I googled for similar problems and found some solutions that doesnt work for me, like some adjusts on config.xml:
```html
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<!-- these below -->
<access origin="*" />
<preference name="hostname" value="localhost" />
<preference name="AndroidInsecureFileModeEnabled" value="true" />
```
### Environment, Platform, Device
Windows 11
vscode
Cordova Cli
### Version information
- cordova 12.0.0 (cordova-lib@12.0.2)
- gradle 8.7
- node v16.16.0
- build tools 34
- platform android 34
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "benerogerio (via GitHub)" <gi...@apache.org>.
benerogerio commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744287301
Yes, this cli makes it much easier to create vue/cordova projects. But since I've been away for a while without releasing new versions, I think I forgot the process a bit, I'm almost sure that using the correct command to build will work.
Anyway, here is the config:
```xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.name" version="1.1.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>AppName</name>
<description></description>
<author email="my@mail.com" href="">
Author
</author>
<hook src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" type="after_prepare" />
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<platform name="android">
<resource-file src="res/android/colors.xml" target="/app/src/main/res/android/colors.xml" />
<icon density="ldpi" foreground="res/android/ldpi.png" density="ldpi" background="res/android/bg-ldpi.png"/>
<icon density="mdpi" foreground="res/android/mdpi.png" density="mdpi" background="res/android/bg-mdpi.png"/>
<icon density="hdpi" foreground="res/android/hdpi.png" density="hdpi" background="res/android/bg-hdpi.png"/>
<icon density="xhdpi" foreground="res/android/xhdpi.png" density="xhdpi" background="res/android/bg-xhdpi.png"/>
<icon density="xxhdpi" foreground="res/android/xxhdpi.png" density="xxhdpi" background="res/android/bg-xxhdpi.png"/>
<icon density="xxxhdpi" foreground="res/android/xxxhdpi.png" density="xxxhdpi" background="res/android/bg-xxxhdpi.png"/>
<config-file parent="/*" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALENDAR"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
</config-file>
<edit-config
file="AndroidManifest.xml"
mode="merge"
target="/manifest/application/service[@android:name='de.appplant.cordova.plugin.background.ForegroundService']"
xmlns:android="http://schemas.android.com/apk/res/android">
<service android:foregroundServiceType="location" />
</edit-config>
<preference name="AndroidXEnabled" value="true" />
</platform>
<preference name="hostname" value="localhost" />
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/android/LembreMeSplashscreen.png" />
<preference name="AndroidWindowSplashScreenBackground" value="#AAAAFF" />
<preference name="SplashScreenDelay" value="1500" />
<preference name="ShowTitle" value="true" />
<preference name="LoadingDialog" value="someText" />
<!-- <preference name="android-minSdkVersion" value="16"/> -->
<preference name="android-targetSdkVersion" value="34"/>
</widget>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744319145
> That's it, worked! Maybe the _**npm cordova-build-android**_ do some more steps on build process because the vue framework. Thanks for the help, I appreciate it! I would end up racking my brains thinking about why it wouldn't work due to that configuration I put in unnecessarily.
oh so removing the `AndroidInsecureFileModeEnabled` did work? Is your main issue resolved?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744268145
Can you provide your full `config.xml`?
> im was using the correct npm cordova-serve-android command to serve on emulator, but i was building with cordova build android --release instead npm cordova-build-android, maybe this is the problem, i'll wait the update to see if it works. Thanks for the help!
`cordova build android --release` / `cordova run android --release` should make the app with release mode, and `run` command will run on device or emulator. Actually publishing to Google Play shouldn't be necessary to test release builds.
the `npm cordova-serve-android` / `npm cordova-build-android` commands are not part of a typical cordova project so I'm not familiar with them or what they do behind the scenes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "benerogerio (via GitHub)" <gi...@apache.org>.
benerogerio commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744257984
I've updated the app with the new release, now the message is:
```html
Application Error
net:ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html)
```
Probably this message is because of the config that you suggest me to remove.
Now i've released a new one, i don't think that it will work. When updated, I think it will show the first message again.
But one new thing that i've done, could work, i forgot that i'm using a plugin called "vue-cli-plugin-cordova" in which he has his own build script, im was using the correct ***npm cordova-serve-android*** command to serve on emulator, but i was building with ***cordova build android --release*** instead ***npm cordova-build-android***, maybe this is the problem, i'll wait the update to see if it works. Thanks for the help!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "benerogerio (via GitHub)" <gi...@apache.org>.
benerogerio closed issue #1791: Getting Application Error net::ERR_CONNECTION_REFUSED on production
URL: https://github.com/apache/cordova-android/issues/1791
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744179814
By using `AndroidInsecureFileModeEnabled` preference you're hosting your web app over the `file://` protocol, which means the webview is not using the WebViewAssetLoader (the thing that listens on `https://localhost`)
`AndroidInsecureFileModeEnabled` is available for legacy reasons, in most cases you should not use it. Therefore I'd recommend removing it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "benerogerio (via GitHub)" <gi...@apache.org>.
benerogerio commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744358837
Yes, problem solved. Looking for a solution, I put AndroidInsecureFileModeEnabled, this was causing the 2nd error message, without it, it was showing the 1st error message, so I think it was the build command, the vue/cordova project has its own structure, cordova structure (src_cordova folder) inside a vue structure, what I was doing is using the build cordova command inside the "src_cordova", maybe building the build this way be sure to consider something related to vue in the build process causing the problem, I will make the suggested adjustments in the config.xml. Thankyou again!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744318081
k, all that looks fine to me. You do have some old deprecated stuf like `AndroidXEnabled` (which is now forcefully enabled, cordova no longer supports non-androidx stuff) but nothing that would cause your main complaint.
>
cordova 12.0.0 (cordova-lib@12.0.2)
gradle 8.7
node v16.16.0
build tools 34
platform android 34
So I had a re-look at your environment and I noticed that the cordova platform version is missing. You can find which platform is installed and their versions using `cordova platform ls`, which should look something like:
```
$ cordova platform ls
Installed platforms:
android 13.0.0
Available platforms:
browser
electron
```
If you're not already using cordova-android@13, then it would be time to upgrade by doing:
```
cordova platform remove android
cordova platform add android@13
```
Or whatever what the vue CLI equivalent commands are.
> Application Error
> net:ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html)
It is strange because this is now indicating that the app is trying to load over `file://` which it should only do if `AndroidInsecureFileModeEnabled` preference was enabled.
```xml
<preference name="hostname" value="localhost" />
```
This usually accompanied with the `scheme` preference, which must be platform-specific (android only allows http or https, whereas iOS allows anything that isn't already "claimed", so it doesn't allow http or https). So something that is worth trying is to move that preference to the `<platform name="android">` block, with the scheme hostname:
```xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.name" version="1.1.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
...
<platform name="android">
<preference name="scheme" value="https" />
<preference name="hostname" value="localhost" />
</platform>
</widget>
```
I'm not really confident that will actually solve anything, because the android platform **should** by default use schemes. with `https://localhost` being the default scheme. But if you were going to define something, that posted example above will be more proper.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [I] Getting Application Error net::ERR_CONNECTION_REFUSED on production [cordova-android]
Posted by "benerogerio (via GitHub)" <gi...@apache.org>.
benerogerio commented on issue #1791:
URL: https://github.com/apache/cordova-android/issues/1791#issuecomment-2744316616
That's it, worked!
Maybe the ***npm cordova-build-android*** do some more steps on build process because the vue framework.
Thanks for the help, I appreciate it! I would end up racking my brains thinking about why it wouldn't work due to that configuration I put in unnecessarily.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org