uni-app云打包一直失败requested TLS protocol versions: (TLSv1.2, TLSv1.3)
uni-app云打包一直失败requested TLS protocol versions: (TLSv1.2, TLSv1.3)
问题描述
-
What went wrong:
- Execution failed for task ‘:app:mergeReleaseNativeLibs’.
Could not resolve all files for configuration ‘:app:releaseRuntimeClasspath’. Could not resolve com.lqr.adapter:library:1.0.2. Required by: project :app Could not resolve com.lqr.adapter:library:1.0.2. Could not get resource ‘https://maven.aliyun.com/repository/public/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’. Could not GET ‘https://maven.aliyun.com/repository/public/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’. The server may not support the client’s requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. For more on this, please refer to Gradle documentation. Remote host terminated the handshake Could not resolve com.lqr.adapter:library:1.0.2. Could not get resource ‘https://repo.maven.apache.org/maven2/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’. Could not GET ‘https://repo.maven.apache.org/maven2/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’. The server may not support the client’s requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. For more on this, please refer to Gradle documentation. Remote host terminated the handshake Could not resolve com.lqr.adapter:library:1.0.2. Could not get resource ‘https://dl.google.com/dl/android/maven2/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’. Could not GET ‘https://dl.google.com/dl/android/maven2/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’. The server may not support the client’s requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. For more on this, please refer to Gradle documentation.
- Execution failed for task ‘:app:mergeReleaseNativeLibs’.
-
Cause 1:
- org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve com.lqr.adapter:library:1.0.2.
- Caused by: org.gradle.api.resources.ResourceException: Could not get resource ‘https://maven.aliyun.com/repository/public/com/lqr/adapter/library/1.0.2/library-1.0.2.pom’.
- at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
- at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
- at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadByCoords(DefaultExternalResourceArtifactResolver.java:154)
- at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:94)
- at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveArtifact(DefaultExternalResourceArtifactResolver.java:60)
- at org.gradle.api.internal.artifacts.repositories.metadata.AbstractRepositoryMetadataSource.parseMetaDataFromArtifact(AbstractRepositoryMetadataSource.java:79)
- at org.gradle.api.internal.artifacts.repositories.metadata.AbstractRepositoryMetadataSource.create(AbstractRepositoryMetadataSource.java:69)
- at org.gradle.api.internal.artifacts.repositories.metadata.DefaultMavenPomMetadataSource.create(DefaultMavenPomMetadataSource.java:40)
- at org.gradle.api.internal.artifacts.repositories.metadata.RedirectingGradleMetadataModuleMetadataSource.create(RedirectingGradleMetadataModuleMetadataSource.java:52)
- at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:235)
- at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:108)
- at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveComponentMetaData(ExternalResourceResolver.java:427)
我也遇到了类似问题 我是升级了Hbuilderx版本到4.44导致的 回退到我之前的4.29可以了
在解决uni-app云打包一直失败,并且出现“requested TLS protocol versions: (TLSv1.2, TLSv1.3)”这类问题时,通常这涉及到SSL/TLS协议配置或者云服务器环境的问题。虽然直接给出建议可能不完全符合你的要求,但我可以提供一个检查和解决这类问题的代码和配置示例,帮助你定位并可能解决问题。
首先,确保你的开发环境和uni-app的依赖都是最新的,因为老版本的工具链可能不支持最新的TLS协议。
1. 检查Node.js版本
uni-app的云打包通常依赖于Node.js环境,确保你的Node.js版本支持TLSv1.2和TLSv1.3。Node.js v10.x及以上版本通常支持TLSv1.2,而TLSv1.3的支持则从v12.0.0开始。
node -v
如果版本过旧,升级Node.js到最新版本。
2. 配置HTTPS请求
如果你在代码中直接进行了HTTPS请求,确保请求库(如axios, request等)配置正确。以下是一个使用axios进行HTTPS请求时,确保使用TLSv1.2或更高版本的示例:
const axios = require('axios');
const https = require('https');
const agent = new https.Agent({
rejectUnauthorized: true, // 验证证书
secureOptions: require('constants').SSL_OP_NO_TLSv1 | require('constants').SSL_OP_NO_TLSv1_1, // 禁用TLSv1和TLSv1.1
});
axios.get('https://example.com', { httpsAgent: agent })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error fetching data:', error);
});
3. 检查云服务器配置
如果你使用的是云服务(如阿里云、腾讯云等),检查云服务器的安全组和网络ACL设置,确保443端口(HTTPS)是开放的,并且服务器上的SSL/TLS配置是正确的。你可能需要联系云服务提供商获取帮助,确保服务器支持TLSv1.2和TLSv1.3。
4. 清理缓存和重新打包
有时候,简单的清理项目缓存和重新进行云打包可以解决问题:
# 清理npm缓存
npm cache clean --force
# 重新安装依赖
npm install
# 重新进行云打包
# 具体命令根据你的uni-app配置而定
如果上述步骤仍然无法解决问题,建议查看uni-app的官方文档或者社区论坛,看看是否有其他开发者遇到并解决了类似的问题。