在RN Android模拟器上取得外部资源失败

问题描述:

尝试使用Genymotion 2仿真器和Custom Phone - 7.0.0 - API 24 - 768x1280 - 7.0以及通过USB MotoG3 - 6.0.1插入的真实设备。在RN Android模拟器上取得外部资源失败

在这两种情况下,在外部托管的工作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模拟器一起工作。

+0

而同样的错误在真实设备上,以及 –

我修复了我的SSL证书。

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