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,搞定。