Native app Network request failed error

Hi, Recently we upgrade our Mendix version from 8.6.0 to 8.6.3 and regenerated the android app using native template version 3.2.2 When starting the app, the following error message popups “A connection error occured” message, please try again later” And in the logs it shows the following logline: ReactNativeJS: 'Network request failed', 'construct@[native code]\ Important to note is that the server uses a SSL certificate, which is singed by a custom CA, which is imported in the android device. In chrome the mendix homepage loads without any problems, However in the native app it does not seem to accept the connection.    Did anybody experience similar issues?
1 answers

In the end I was able to find the solution myself, which I'll share below.

As mentioned in the post the Mendix server used a SSL certificate which is signed by an internal custom CA. 
By default behavior custom/user-added CA's are disabled, unless explicitly allowed via the network security configuration of the APK. See, the documentation below for a more detailed explanation.

“By default, secure connections (using protocols like TLS and HTTPS) from all apps trust the pre-installed system CAs, and apps targeting Android 6.0 (API level 23) and lower also trust the user-added CA store by default.”

The solution is as follows:

  1. Prepare the project using the native builder to generate a github project (skip if it already exists)
  2. In the github master branch add the file  "app/src/main/res/xml/network_security_config.xml”
       <?xml version="1.0" encoding="utf-8"?>
        <base-config cleartextTrafficPermitted="false">
                <certificates src="system" />
                <certificates src="user" />
  3. Add the “networkSecurityConfig” line directly after the application tag in app/src/main/AndroidManifest.xml
  4. Now proceed with the native builder command as usual.
    During this step the network_security_config.xml will be included in the apk.
    When installing custom CA/self-signed certificates on the android device, these will be taken into account.