arcgis runtime sdk for android 系列 - 简单却又恼人的小问题 之修改hosts文件与接受自签名证书
分享
目的:
一般只有在开发测试初期才需要这么做。后期应用程序正式上线肯定不会需要这些操作的。
修改hosts目的是为了能让安卓识别到ArcGIS Enterprise域名。
接受自签名证书目的是为了接受ArcGIS Enterprise自签名证书,客户端可以继续与服务器端通信。
修改安卓hosts文件:
1 以下以模拟器为例,首先确认要启动的模拟器的名字:
2 在Android Studio的终端(terminal)中启动模拟器。
D:\Program Files\AndroidSDK\emulator>emulator -avd pixel -writable-system
继续在终端获取root权限(注意在不同目录下)
D:\Program Files\AndroidSDK\platform-tools>adb root
D:\Program Files\AndroidSDK\platform-tools>adb remount
//将模拟器中的hosts文件下载到本地D:\test
D:\Program Files\AndroidSDK\platform-tools>adb pull /system/etc/hosts D:\test
//在hosts添加完成IP与机器名映射后,push回模拟器
D:\Program Files\AndroidSDK\platform-tools>adb push D:\test\hosts /system/etc/hosts
3 在这一步执行完毕后,可以在模拟器的浏览器中测试访问添加到hosts中的新域名。
在安卓程序中接受自签名证书:
用以下一句代码即可搞定自签名证书:
authenticationManager.setTrustAllSigners(true);
注:该方法不通过已经过期的自签名证书。
参考:
https://blog.csdn.net/mq255329 ... 65469
https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/security/AuthenticationManager.html
原文:
http://www.gougexueli.com/2018 ... 25A5/
一般只有在开发测试初期才需要这么做。后期应用程序正式上线肯定不会需要这些操作的。
修改hosts目的是为了能让安卓识别到ArcGIS Enterprise域名。
接受自签名证书目的是为了接受ArcGIS Enterprise自签名证书,客户端可以继续与服务器端通信。
修改安卓hosts文件:
1 以下以模拟器为例,首先确认要启动的模拟器的名字:
2 在Android Studio的终端(terminal)中启动模拟器。
D:\Program Files\AndroidSDK\emulator>emulator -avd pixel -writable-system
继续在终端获取root权限(注意在不同目录下)
D:\Program Files\AndroidSDK\platform-tools>adb root
D:\Program Files\AndroidSDK\platform-tools>adb remount
//将模拟器中的hosts文件下载到本地D:\test
D:\Program Files\AndroidSDK\platform-tools>adb pull /system/etc/hosts D:\test
//在hosts添加完成IP与机器名映射后,push回模拟器
D:\Program Files\AndroidSDK\platform-tools>adb push D:\test\hosts /system/etc/hosts
3 在这一步执行完毕后,可以在模拟器的浏览器中测试访问添加到hosts中的新域名。
在安卓程序中接受自签名证书:
用以下一句代码即可搞定自签名证书:
authenticationManager.setTrustAllSigners(true);
注:该方法不通过已经过期的自签名证书。
参考:
https://blog.csdn.net/mq255329 ... 65469
https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/security/AuthenticationManager.html
原文:
http://www.gougexueli.com/2018 ... 25A5/