Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

android - Force Gradle to use HTTP instead of HTTPS

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 occurred configuring root project 'MobileApp'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:1.3.1.
     Required by:
         :MobileApp:unspecified
      > Could not resolve com.android.tools.build:gradle:1.3.1.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.3.1/gradle-1.3.1.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.3.1/gradle-1.3.1.pom'.
               > Connection to https://jcenter.bintray.com refused

The issue is clear, I am sitting behind corporate proxy that blocks any HTTPSconnections like these in error. So my questions are: how to force gradle to use HTTP in loading these files? Where these properties should be put(which of gradle files, i.e. gradle.properties)?

P.S. I already have set these in gradle properties file:

systemProp.http.proxyHost= myHost
systemProp.http.proxyPort= myPort
systemProp.http.proxyUser= myUser
systemProp.http.proxyPassword= myPassword

Any links, suggestions or etc. will help a lot.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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" }
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...