在RN Android模拟器中获取外部资源失败

时间:2017-10-07 07:47:05

标签: android react-native-android

尝试使用带有Custom Phone - 7.0.0 - API 24 - 768x1280 - 7.0的Genymotion 2模拟器以及通过USB MotoG3 - 6.0.1插入的真实设备。

在这两种情况下,对外部托管的工作JSON API进行提取失败。

"TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:12473:16)
    at XMLHttpRequest.dispatchEvent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:13376:35)
    at XMLHttpRequest.setReadyState (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:15481:18)
    at XMLHttpRequest.__didCompleteResponse (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:15337:14)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:15432:45
    at RCTDeviceEventEmitter.emit (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:3958:35)
    at MessageQueue.__callFunction (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:2090:42)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1948:15
    at MessageQueue.__guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:2062:9)
    at MessageQueue.callFunctionReturnFlushedQueue (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1947:12)"

同样适用于ios模拟器。

以下报告的问题没有帮助 https://github.com/facebook/react-native/issues/5222 https://github.com/facebook/react-native/issues/15100

我的问题是(我知道java但不够Android) - 我在哪里查找任何日志/例外以了解它失败的真正原因。因为API本身是有用的,并且正在使用IOS模拟器。

1 个答案:

答案 0 :(得分:0)

我修复了我的证书。

https://in.godaddy.com/community/SSL-And-Security/SSL-Certificate-Issue-Android/td-p/49469

我必须编写一个Android HelloWorld应用程序才能进入javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

https://developer.android.com/training/articles/security-ssl.html#CommonProblems