apply Network Security Config file (fixes #22375) (part 2 of #23105) (#23135)

Summary:
This is a follow-up PR for https://github.com/facebook/react-native/pull/23105 - as mentioned on discord.

 ---

This PR applies the network security config for the RN template project only. New RN projects started with the updated template will be able to connect to the packager on builds built with Android API 28 & above.

See https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted for more information about this newly required config, specifically:

![image](https://user-images.githubusercontent.com/5347038/52124287-b3de2580-2620-11e9-958d-bc2da15c6f01.png)

Changelog:
----------
[ANDROID] [Template] add Network Security Config file to allow access to packager via cleartext requests in Android API 28 and above. (fixes #22375)
Pull Request resolved: https://github.com/facebook/react-native/pull/23135

Differential Revision: D13917058

Pulled By: cpojer

fbshipit-source-id: 0e66f2cde712c1285d217e3625b73028c3770b65
This commit is contained in:
Salakar 2019-02-01 06:33:04 -08:00 committed by Facebook Github Bot
parent 32cb9ec49c
commit 84572c4051
3 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.helloworld">
xmlns:tools="http://schemas.android.com/tools"
package="com.helloworld">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
@ -10,7 +11,9 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
<activity
android:name=".MainActivity"
android:label="@string/app_name"

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="false">localhost</domain>
<domain includeSubdomains="false">10.0.2.2</domain>
<domain includeSubdomains="false">10.0.3.2</domain>
</domain-config>
</network-security-config>