jenkins+AndroidStudio整合报错 classpath:gradle XXXXXX

jenkins打包没问题,jenkins出现报错。

报错内容:

Here are the highlights of this release:
 - Incremental Java compilation by default
 - Periodic Gradle caches cleanup
 - Gradle Kotlin DSL 1.0-RC6
 - Nested included builds
 - SNAPSHOT plugin versions in the `plugins {}` block

For more details see https://docs.gradle.org/4.10.2/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'workspace'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.2.0.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.2.0.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.0/gradle-3.2.0.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.0/gradle-3.2.0.pom'. Received status code 400 from server: Bad Request
      > Could not resolve com.android.tools.build:gradle:3.2.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.0/gradle-3.2.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.0/gradle-3.2.0.pom'. Received status code 400 from server: Bad Request

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE

  

参考:

https://juejin.im/post/5ab3574851882577b45eec48

里面提到AndroidStudio的terminal里面直接用命令行语句 gradle clean查看是不是会报错,试了下确实会。

参考:

https://blog.csdn.net/itfootball/article/details/45023805

里面提到将build.gradle修改一下,增加google()

buildscript {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        google()
    }
    dependencies{
        classpath 'com.android.tools.build:gradle:3.2.0'
    }
}

  

后面出现http 400报错,查了一下,说报错的这个gradle版本,是指androidStudio的gradle plugin的版本,不是gradle的版本。

其对应关系参考:

https://developer.android.google.cn/studio/releases/gradle-plugin.html#updating-plugin

 

我安装的gradle是4.10.2版本,在build.gradle里面把gradle plugin的版本改成了对应的3.3.0版本

buildscript {
    
    repositories {
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

  

然后还是报错400,又查了下,说是代理设置的问题,我在androidstudio上面没有设置过代理,查了项目的gradle的配置,也没有代理,最后查看本地最开始安装的gradle的配置,原来是最开始安装gradle的时候配置了代理。

参考:

https://blog.csdn.net/lqx_sunhan/article/details/82633275

 

于是找到自己当初的gradle安装的系统目录的gradle.properties,默认在C盘User里面,我的路径是:

C:\Users\user\.gradle\gradle.properties

  

将该文件的末尾的4行代理设置,注释掉:

#systemProp.https.proxyPort=80
#systemProp.http.proxyHost=mirrors.neusoft.edu.cn
#systemProp.https.proxyHost=mirrors.neusoft.edu.cn
#systemProp.http.proxyPort=80

  

重启AndroidStudio,搞定。

posted @ 2019-07-18 17:15  头鹰在学习  阅读(1230)  评论(0编辑  收藏  举报