以下:https://facebook.github.io/react-native/docs/getting-started.html, 我创建了一个空项目并尝试通过执行以下操作来运行它: sudo 反应本机运行 android 这是生产出来的:
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug...
Downloading https://services.gradle.org/distributions/gradle-2.4-all.zip
Exception in thread "main" javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
(如果有用的话,我可以发布其余的错误)。有人有什么建议吗?
更改分发网址:
android/gradle/wrapper/gradle-wrapper.properties
从
https
到http
。
使用以下步骤我解决了错误:
更改 src task downloadBoost 的路径 http://mirror.nienbo.com/boost/1.57.0/boost_1_57_0.zip
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
// Use ZIP version as it's faster this way to selectively extract some parts of the archive
//src 'https://downloads.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.zip'
// change
src 'http://mirror.nienbo.com/boost/1.57.0/boost_1_57_0.zip'
onlyIfNewer true
overwrite false
dest new File(downloadsDir, 'boost_1_57_0.zip')
}
执行 Gradle 同步
工具 -> Android -> 将项目与 Gradle 文件同步
将 /android/gradle/wrapper/gradle-wrapper.properties 中的分发 URL 从 https 更改为 http,并将 gradle 版本从 5.4 更改为 5.5
按照以下步骤操作
下载根证书
在 Chrome 浏览器中打开任意网站,然后单击网址栏 ->
连接安全 -> 证书有效 -> 详细信息选项卡 -> 导出
以“Der-encoded 二进制,单一证书”格式导出上述证书。并使用 example
保存文件将此证书文件保存在 C:\Program Files (x86)\Java\jre\lib\security\ 位置。
如果您使用的是 mac,请将其保存在 /Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home/lib/security/
运行命令
keytool -import -alias example -keystore "C:\Program Files (x86)\Java\jre\lib\security" -file example.cer
如果询问密码,请提供默认密码更改