Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Android: Cannot send data to the server. CLEARTEXT communication to not permitted by network security policy #269

Open
LubomirKovalcik opened this issue Feb 12, 2020 · 7 comments

Comments

@LubomirKovalcik
Copy link

Your Environment

  • Uploader Version Number: 0.7.1
  • Your Android Phone Model Name (e.g. Samsung J1 Ace): Xiamo Mi9
  • Android Version Number (e.g. use 4.4 for 4.4.4): 10 QKQ1
  • Network Connection at the time the issue occurred (Wi-Fi, Mobile): WiFi / Mobile
  • Nightscout website version (e.g. 0.8.4 Funnel cake, master / dev branch): nightscout
    version 0.11.1

Brief Explanation of Issue

When trying to upload data to Nighscout, it throws error:

Android: Cannot send data to the server. CLEARTEXT communication to not permitted by network security policy

Uploader Error Code

Android: Cannot send data to the server. CLEARTEXT communication to not permitted by network security policy

Steps to Reproduce (for bugs)

  1. Setup nighscout URL and API key
  2. Connect Countour uploader USB
  3. Wait for data loading from Countour
  4. Throws error when trying to upload to Nighscout
@Pogman
Copy link
Collaborator

Pogman commented Feb 12, 2020

Your Nightscout URL address in the uploader needs to be in this form:
https://sitename.herokuapp.com

@LubomirKovalcik
Copy link
Author

I do not have https on my nightscout page. I am not using heroku or other cloud.

@Pogman
Copy link
Collaborator

Pogman commented Feb 12, 2020

Ah ok , the uploader will only work with https.

You can build the uploader with the follow changes to make it work with http:

Add src\main\res\xml\network_security_config.xml file with the following content:

<?xml version="1.0" encoding="utf-8"?>
<network_security_config xmlns:android="http://schemas.android.com/apk/res/android">
    <domain-config cleartextTrafficPermitted="true">
    </domain-config>
</network_security_config>

Add this line into AndroidManifest.xml as part of the application declarations:

android:networkSecurityConfig="@xml/network_security_config"

It will look like this when added:

    <application
        android:name=".UploaderApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:theme="@style/AppTheme">

@Fix3l
Copy link

Fix3l commented Mar 4, 2020

Hi I'm not a developer and struggle during AndroidStuidio setup.
Both Fabric and BugFender aren't available right now and if i try do build the project without them i get a gradle sync error.
is there an easier way to build the apk with the changes above?

@steve8x8
Copy link

steve8x8 commented Mar 4, 2020

@Fix3l did you upgrade gradle by accident?

@Fix3l
Copy link

Fix3l commented Mar 4, 2020

Hm the first errors told that fabric isn't reachable or something. Androidstudio recommended to work in offline mode.
After that the gradlesync error appears.

@Sven-needs-help
Copy link

Dear all,

I run into the same issue as mentioned above.
My small son is using the Medtronics minimed 640G pump. I'm using the 600Series Android uploader you provided on the smartphone. Thanks a lot for the APP!
However, I'd like to share the uploaded data on Nightscout on my own Windows Server physically located in my house in order to secure the data don't leave the house.
In order to do so, I installed the Nightscout-on-Windows-Server as described from Jay Lagorio (https://github.com/jaylagorio/Nightscout-on-Windows-Server).
The issue is that the server does not permit https:// as default (see issue No.5).
As I'm not a SW developer I spent many hours but didn't get the server to work with certificates for https://. Since the network between the pump to the server via Smartphone is separated from the internet, I can accept the data to be transmitted by http://.
I don't posses any SW development environment nor I have any knowledge/experience about it. So, is there any chance to get the uploader APP compiled which accepts http:// connections to share the data with the server? If I understand correctly, the proposal is written above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants