Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26377

Android: Allow non-https requests to work when targeting Android P

    Details

      Description

      Summary:
      An Android P device will block cleartext "http" requests by default for apps that target Android P.
      https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted

      The Java HttpUrlConnection on Android P will throw the following exception when attempt to do a non-https request...

      java.io.IOException: Cleartext HTTP traffic to raw.githubusercontent.com not permitted
      

      Steps to reproduce:

      1. Set up "tiapp.xml" to target API Level 28.
      2. Acquire an Android P device that has Internet access.
      3. Build and run HttpGetTest.js on the Android P device.
      4. Tap on the "HTTP Get" button.
      5. Notice that you get a "Cleartext HTTP traffic to <URL> not permitted" error.

      Note:
      This is also an issue with a WebView loading "http:" pages too.
      Can be reproduced with the following...

      var window = Ti.UI.createWindow();
      window.add(Ti.UI.createWebView({ url: "http://www.google.com" }));
      window.open();
      

      Possible Solution:
      Simplest solution may be to set the following "AndroidManifest.xml" <application> attribute "android:usesCleartextTraffic" to true for all Titanium built apps by default. This way apps are backward compatible. But allow the Titanium developer to set this to false in the "tiapp.xml".
      https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic

      Example...

      <manifest>
      	<application android:usesCleartextTraffic="true"/>
      </manifest>
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
            • Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code