reactnativecn / react-native-website

React Native 中文网
https://reactnative.cn
MIT License
216 stars 327 forks source link

初始化0.73版本 执行yarn android 报错 #789

Open daxueguai opened 5 months ago

daxueguai commented 5 months ago

error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'Atest64'.

Could not determine the dependencies of task ':gradle-plugin:compileJava'. > Could not resolve all dependencies for configuration ':gradle-plugin:compileClasspath'. > Using insecure protocols with repositories, without explicit opt-in, is unsupported. * Try: Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/repositories/jcenter)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. For more information, please refer to https://docs.gradle.org/8.3/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol in the Gradle documentation.

sunnylqm commented 5 months ago

maven源应该用https链接,而不是http

fsf678 commented 4 months ago

maven源应该用https链接,而不是http

请问具体怎么解决?

sunnylqm commented 4 months ago

maven源应该用https链接,而不是http

请问具体怎么解决?

这源是自己配置的啊(阿里云的),你自己配置那你就多打个s啊

nxsz commented 1 month ago

可以看一下系统用户目录下的 .gradle/init.gradle 文件中 的 repositories 选项中 的仓库配置 中有两个http协议的阿里云的仓库地址 修改为 https 的保存试试,我也是遇到了相同的问题 搞了两个晚上才定位到问题,我把完整的文件内容贴在下文,希望可以帮助到你。

// init.gradle 文件的完整配置
allprojects{
    repositories {
//       文件中默认的地址是 http 协议的
         //def MY_ALIYUN_REPOSITORY_URL = 'http//maven.aliyun.com/nexus/content/groups/public'
        //def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        // 修正后的内容如下
        def MY_ALIYUN_REPOSITORY_URL = 'https//maven.aliyun.com/nexus/content/groups/public'
        def MY_ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/nexus/content/repositories/jcenter'

        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
            url MY_ALIYUN_REPOSITORY_URL
            url MY_ALIYUN_JCENTER_URL
        }
    }
}
sunnylqm commented 1 month ago

系统是不带这个的,只能是自己很久之前配置过但是又忘了

nxsz commented 1 month ago

系统是不带这个的,只能是自己很久之前配置过但是又忘了

是的,我开了一个虚拟机 进行了测试,安装 AS 之后会在 系统用户目录下初始化一个 /.gradle 目录 ,确实没有init.gradle 文件。可能是因为其他原因配置过这个文件。

经过调查 init.gradle 起到一个全局注入的作用 并且优先级不低,在 gradle 不强制要求仓库链接使用 https 的协议的时候就得配置是没有问题的 在 grade 7.0 版本以后 就开始要求仓库链接使用 https 所以才会出现的类似问题

总结一下:这就是因为用户的一些环境配置导致的问题 我的回答仅仅作为一个排查方向