0

I have an application in Cordova 11.1.0. When I generate the debug APK, it connects to the server via HTTPS without any problem, but when I sign the APK, it doesn't connect. To create the release, I run:

cordova `build android --release' which generates the .abb file. Later, I run:
java -jar bundletool.jar build-apks --mode universal  --bundle=app-release.aab --output=App.apks --ks=app.keystore --ks-pass=pass:XXXXXX --ks-key-alias=XXXX

Then, I decompress the file with the .apks extension and install the APK that is inside.

I don't know if it's a problem with the app signing process or if it's an error with the application itself.

I used another command:

cordova run android --release -- --keystore=xxxxx.keystore --storePassword=xxxxxx --alias=xxxxx --password=xxxxx --packageType=apk

To sign and generate the apk, but I have the same problem.

I change in my config.xml this:

<preference name="android-minSdkVersion" value="29" />
<preference name="AndroidXEnabled" value="true" />
<preference name="SplashMaintainAspectRatio" value="true" />
**<preference name="scheme" value="https" />
<preference name="hostname" value="my.host" />**

**<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>**```

But the problem is the same.
  • does it work if you upload the .aab file to Google Play Console with schene https ? – Eric Apr 14 '23 at 19:47
  • @eric I cannot can test that because this app is for a company and I don't have access the google play account. But I think that not is the problem, because, I generate a a apk with the command : 'cordova run android --release -- --keystore=xxxxx.keystore --storePassword=xxxxxx --alias=xxxxx --password=xxxxx --packageType=apk` And the problem is the same, with this apk generated cannot login. – Rodrigo Perugachi Apr 15 '23 at 10:29

2 Answers2

1

How I said, I made a mobile application with apache-cordova. This application when run in debug it's work, but when sign the app, the connection with https has refused. The connection in this case are refused because the services are not in the public access only is avalable in internal network.

I solved the error follow the next steps.

  1. Install in android device the certificates, Go to Security and find the install certifcates options inside the menu, in each devices are different.

  2. In cordova application in config.xml file, put the next preferences under tag platform name="android"

  3. Create in platforms\android\app\src\res\xml the file network_security_config.xml with this content:

     <network-security-config>  
           <base-config>  
                 <trust-anchors>  
                     <!-- Trust preinstalled CAs -->  
                     <certificates src="system" />  
                     <!-- Additionally trust user added CAs -->  
                     <certificates src="user" />  
                </trust-anchors>  
           </base-config>  
      </network-security-config>
    
  4. In AndroidManifest.xml add in the tag <application .... the tag android:networkSecurityConfig="@xml/network_security_config"

That's all.

0

Check if in your config.xml you have these entries

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

Also you can create a build.json file in the cordova app root and get rid of all the keystore configs in you build command.

{
  "android": {
    "debug": {
        "keystore": "relative/path/to/debug.keystore",
        "storePassword": "mypass",
        "alias": "myalias",
        "password" : "mypass",
        "keystoreType": ""
    },
    "release": {
        "keystore": "relative/path/to/release.jks",
        "storePassword": "mypass",
        "alias": "myalias",
        "password" : "mypass",
        "keystoreType": ""
    }
}}

Try also to debug any error in console, follow my answer here deviceready Event not fired in an Angular hybrid app.

And if you need more logs, you can use ADB logcat.

Sergio Rinaudo
  • 2,303
  • 15
  • 20
  • Hello. I have this entries in config.xml file: `` `` `` `` `` I have created a build.json and run build again, the apk had been generated and install in my phone, but when I try to login, show me a error, the connections are not available in a signed application. Is so weird because when I run `cordova -run android --device` the application works, but when sign the app and install does not work. – Rodrigo Perugachi Apr 15 '23 at 10:18