Last active
November 4, 2019 22:01
-
-
Save RaschidJFR/769d39cdbe8f986d29cd4ad9bc464345 to your computer and use it in GitHub Desktop.
Revisions
-
RaschidJFR revised this gist
Nov 4, 2019 . 1 changed file with 19 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ # Setup for connecting Android Emulatir with live reload to local host PC How to create a configuration to run with `$ ionic cordova emulate android -l -c local` and let the emulator connect to host PC, accessing through `10.0.2.2` instead if `localhost`. ## 1 angular.json Create the file `environment.local.emulator.ts`. Then appli these changes to `angular.json`. 1. Add this snippet under `project.app.architect.build.configurations`: @@ -41,17 +42,24 @@ Create the file `environment.local.emulator.ts`. Then appli these changes to `an }, ``` ## 2 config.xml Enable connections to host PC through `10.0.2.2`. 1. Add this to `config.xml`: ```xml <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" /> ``` 2 Add this to `resources/android/xml/network_security_config.xml` (or create it if it does not exist): ```xml <?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">localhost</domain> <domain includeSubdomains="true">10.0.2.2</domain> <!-- Add this line to enable connecting to host PC --> </domain-config> </network-security-config> ``` -
RaschidJFR created this gist
Nov 4, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ Create a configuration for connecting to live reload with: `ionic cordova emulate android -l -c local`. ## angular.json Create the file `environment.local.emulator.ts`. Then appli these changes to `angular.json`. 1. Add this snippet under `project.app.architect.build.configurations`: ```json "local-emulator": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.local.emulator.ts" } ] }, ``` 2. Add this under `project.app.architect.serve.configurations`: ```json "local-emulator": { "browserTarget": "app:build:local-emulator" }, ``` 3. Add this under `project.app.architect.ionic-cordova-build.configurations`: ```json "local": { "browserTarget": "app:build:local-emulator" } ``` 4. Add this under `project.app.architect.ionic-cordova-serve.configurations`: ```json "local": { "cordovaBuildTarget": "app:ionic-cordova-build:local", "devServerTarget": "app:serve:local-emulator" }, ``` ## config.xml Enable connections to host PC through `10.0.2.2`. 1. Add this under `<platform name="android">` ```xml <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">10.0.2.2</domain> </domain-config> </network-security-config> </edit-config> ```