Force Gradle to use HTTP instead of HTTPS

前端 未结 4 948
清歌不尽
清歌不尽 2020-12-15 06:00

I am trying to build react-native android app, as a dependecy I see I have gradle, but it fails to load on build. Error message:

* What went wrong:
A problem         


        
相关标签:
4条回答
  • 2020-12-15 06:29

    I had same problem and fixed it.

    gradle is forced to get dependencies from jcenter through https proxy.

    if you add

    maven { url "http://jcenter.bintray.com" }
    

    in your repositories instead of jcenter(), gradle sees this repository as a simple maven repository with http proxy.

    your project build.gradle should be like below:

    buildscript {
        repositories {
            maven { url "http://jcenter.bintray.com" }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.1'
        }
    }
    
    allprojects {
        repositories {
            maven { url "http://jcenter.bintray.com" }
        }
    }
    
    0 讨论(0)
  • 2020-12-15 06:33

    replace jcenter() with jcenter { url "http://jcenter.bintray.com/"} in build.gradle

    0 讨论(0)
  • 2020-12-15 06:45

    Try this

    • run a proxy like freegate

    • the root path project in cmd type

      gradlew -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8580

    File -> Settings -> Project Settings -> Gradle -> Global Gradle Settings -> Gradle VM Options

    -Dhttp.proxyHost=myProxyAddr
    -Dhttp.proxyPort=myProxyPort
    -Dhttp.proxyUser=myUsername
    -Dhttp.proxyPassword=myPasswd 
    -Dhttp.auth.ntlm.domain=myDomainName
    
    0 讨论(0)
  • 2020-12-15 06:47

    Go into the gradle/wrapper folder nearby and edit the gradle-wrapper.properties

    Then add in a the https to the distribution URL and it should work.

    distributionUrl=https\://services.gradle.org/distributions/gradle-1.10-bin.zip
                        ^
    

    Verify the file you are trying to grab is actually on the repo:

    https://services.gradle.org/distributions/

    Rerun your command to get the gradle wrapper version.

    gradle wrapper
    gradlew.bat wrapper -gradle-version="1.10"
    

    Hope that helps.

    0 讨论(0)
提交回复
热议问题