更新完Android Studio 3.0 Canary 2后错误是这样的:
Error:A problem occurred configuring root project 'xxx'.
> Could not resolve all files for configuration ':classpath'.
> Could not download builder.jar (com.android.tools.build:builder:3.0.0-alpha1)
> Could not get resource 'https://maven.google.com/com/android/tools/build/builder/3.0.0-alpha1/builder-3.0.0-alpha1.jar'.
> Could not GET 'https://maven.google.com/com/android/tools/build/builder/3.0.0-alpha1/builder-3.0.0-alpha1.jar'.
> Connect to maven.google.com:443 [maven.google.com/216.58.200.46] failed: Connection timed out: connect
一开始我以为是被墙了,挂上VPN点击“Invalidate Caches / Restart”清除缓存重启,可是问题还在,于是我又开始逛Google和Stackoverflow,找到了一个方法:
Mac/Linux:
./gradlew tasks --offline
1
Windows:
gradlew tasks --offline
1
可是结果并不如我想的那么乐观,电脑本地没有新版本相关文件的缓存:
D:\AndroidStudioProjects\xxx>gradlew tasks --offline
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'xxx'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4.
Required by:
project :
> No cached version of org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4 available for offline mode.
> No cached version of org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4 available for offline mode.
> Could not resolve com.android.tools.external.com-intellij:uast:171.4249.33.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.lint:lint:26.0.0-alpha1 > com.android.tools.lint:lint-checks:26.0.0-alpha1 > com.android.tools.lint:lint-api:26.0.0-alpha1
> No cached version of com.android.tools.external.com-intellij:uast:171.4249.33 available for offline mode.
> No cached version of com.android.tools.external.com-intellij:uast:171.4249.33 available for offline mode.
> Could not resolve org.ow2.asm:asm-util:5.0.4.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1
> No cached version of org.ow2.asm:asm-util:5.0.4 available for offline mode.
> No cached version of org.ow2.asm:asm-util:5.0.4 available for offline mode.
> Could not resolve net.sf.proguard:proguard-gradle:5.3.3.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1
> No cached version of net.sf.proguard:proguard-gradle:5.3.3 available for offline mode.
> No cached version of net.sf.proguard:proguard-gradle:5.3.3 available for offline mode.
> Could not resolve org.jacoco:org.jacoco.core:0.7.4.201502262128.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1
> No cached version of org.jacoco:org.jacoco.core:0.7.4.201502262128 available for offline mode.
> No cached version of org.jacoco:org.jacoco.core:0.7.4.201502262128 available for offline mode.
> Could not resolve org.jacoco:org.jacoco.report:0.7.4.201502262128.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1
> No cached version of org.jacoco:org.jacoco.report:0.7.4.201502262128 available for offline mode.
> No cached version of org.jacoco:org.jacoco.report:0.7.4.201502262128 available for offline mode.
> Could not resolve org.bouncycastle:bcpkix-jdk15on:1.56.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools:sdk-common:26.0.0-alpha1
> No cached version of org.bouncycastle:bcpkix-jdk15on:1.56 available for offline mode.
> No cached version of org.bouncycastle:bcpkix-jdk15on:1.56 available for offline mode.
> Could not resolve org.bouncycastle:bcprov-jdk15on:1.56.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools:sdk-common:26.0.0-alpha1
> No cached version of org.bouncycastle:bcprov-jdk15on:1.56 available for offline mode.
> No cached version of org.bouncycastle:bcprov-jdk15on:1.56 available for offline mode.
> Could not resolve org.jetbrains.kotlin:kotlin-runtime:1.0.5.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.lint:lint:26.0.0-alpha1
> No cached version of org.jetbrains.kotlin:kotlin-runtime:1.0.5 available for offline mode.
> No cached version of org.jetbrains.kotlin:kotlin-runtime:1.0.5 available for offline mode.
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.0.5.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.lint:lint:26.0.0-alpha1
> No cached version of org.jetbrains.kotlin:kotlin-stdlib:1.0.5 available for offline mode.
> No cached version of org.jetbrains.kotlin:kotlin-stdlib:1.0.5 available for offline mode.
> Could not resolve com.google.guava:guava:19.0.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:gradle-api:3.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.databinding:compilerCommon:3.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools:common:26.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools.analytics-library:shared:26.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools.analytics-library:tracker:26.0.0-alpha1
> No cached version of com.google.guava:guava:19.0 available for offline mode.
> No cached version of com.google.guava:guava:19.0 available for offline mode.
> Could not resolve com.google.code.gson:gson:2.3.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools:sdklib:26.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools.build:manifest-merger:26.0.0-alpha1
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools.analytics-library:shared:26.0.0-alpha1
> No cached version of com.google.code.gson:gson:2.3 available for offline mode.
> No cached version of com.google.code.gson:gson:2.3 available for offline mode.
> Could not resolve org.apache.httpcomponents:httpclient:4.2.6.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools:sdklib:26.0.0-alpha1
> No cached version of org.apache.httpcomponents:httpclient:4.2.6 available for offline mode.
> No cached version of org.apache.httpcomponents:httpclient:4.2.6 available for offline mode.
> Could not resolve com.google.guava:guava:19.0.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.build:builder:3.0.0-alpha1 > com.android.tools:sdklib:26.0.0-alpha1 > com.android.tools:repository:26.0.0-alpha1 > com.google.jimfs:jimfs:1.1
> No cached version of com.google.guava:guava:19.0 available for offline mode.
> No cached version of com.google.guava:guava:19.0 available for offline mode.
> Could not resolve com.google.guava:guava:19.0.
Required by:
project : > com.android.tools.build:gradle:3.0.0-alpha1 > com.android.tools.build:gradle-core:3.0.0-alpha1 > com.android.tools.lint:lint:26.0.0-alpha1 > com.android.tools.lint:lint-checks:26.0.0-alpha1 > com.android.tools.lint:lint-api:26.0.0-alpha1 > com.android.tools.external.lombok:lombok-
ast:0.2.3
> No cached version of com.google.guava:guava:19.0 available for offline mode.
> No cached version of com.google.guava:guava:19.0 available for offline mode.
> Could not download builder.jar (com.android.tools.build:builder:3.0.0-alpha1): No cached version available for offline mode
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 1s
最后我尝试着去掉“–offline”,在Terminal中再次运行
gradlew tasks
1
等了一会总算下载完成并且重新Build(期间VPN继续挂着)
D:\AndroidStudioProjects\xxx>gradlew tasks
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-4/kotlin-gradle-plugin-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.1.2-4/kotlin-gradle-plugin-api-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.2-4/kotlin-stdlib-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-project/1.1.2-4/kotlin-project-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-android-extensions/1.1.2-4/kotlin-android-extensions-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.1.2-4/kotlin-compiler-embeddable-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-runner/1.1.2-4/kotlin-compiler-runner-1.1.2-4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-annotation-processing/1.1.2-4/kotlin-annotation-processing-1.1.2-4.pom
Download https://maven.google.com/com/android/tools/external/com-intellij/uast/171.4249.33/uast-171.4249.33.pom
Download https://maven.google.com/com/android/tools/build/transform-api/2.0.0-deprecated-use-gradle-api/transform-api-2.0.0-deprecated-use-gradle
-api.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-util/5.0.4/asm-util-5.0.4.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.3.3/proguard-gradle-5.3.3.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-parent/5.3.3/proguard-parent-5.3.3.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.pom
Download https://jcenter.bintray.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.3.3/proguard-base-5.3.3.pom
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.3/gson-2.3.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.2.6/httpclient-4.2.6.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.2.6/httpcomponents-client-4.2.6.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.2.5/httpcore-4.2.5.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-core/4.2.5/httpcomponents-core-4.2.5.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-android-extensions/1.1.2-4/kotlin-android-extensions-1.1.2-4.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-4/kotlin-gradle-plugin-1.1.2-4.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.1.2-4/kotlin-gradle-plugin-api-1.1.2-4.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.2-4/kotlin-stdlib-1.1.2-4.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-runner/1.1.2-4/kotlin-compiler-runner-1.1.2-4.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-annotation-processing/1.1.2-4/kotlin-annotation-processing-1.1.2-4.jar
Download https://maven.google.com/com/android/tools/build/builder/3.0.0-alpha1/builder-3.0.0-alpha1.jar
Download https://maven.google.com/com/android/tools/external/com-intellij/uast/171.4249.33/uast-171.4249.33.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.1.2-4/kotlin-compiler-embeddable-1.1.2-4.jar
Download https://maven.google.com/com/android/tools/build/transform-api/2.0.0-deprecated-use-gradle-api/transform-api-2.0.0-deprecated-use-gradle
-api.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-util/5.0.4/asm-util-5.0.4.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.3.3/proguard-gradle-5.3.3.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.56/bcpkix-jdk15on-1.56.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.56/bcprov-jdk15on-1.56.jar
Download https://jcenter.bintray.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.3.3/proguard-base-5.3.3.jar
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.3/gson-2.3.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.2.6/httpclient-4.2.6.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.2.5/httpcore-4.2.5.jar
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':app' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for each variant.
sourceSets - Prints out all the source sets defined in this project.
Build tasks
-----------
assemble - Assembles all variants of all applications and secondary packages.
assembleAndroidTest - Assembles all the Test applications.
assembleDebug - Assembles all Debug builds.
assembleRelease - Assembles all Release builds.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
clean - Deletes the build directory.
cleanBuildCache - Deletes the build cache directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests.
Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.
Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'xxx'.
components - Displays the components produced by root project 'xxx'. [incubating]
dependencies - Displays all dependencies declared in root project 'xxx'.
dependencyInsight - Displays the insight into a specific dependency in root project 'xxx'.
dependentComponents - Displays the dependent components of components in root project 'xxx'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'xxx'. [incubating]
projects - Displays the sub-projects of root project 'xxx'.
properties - Displays the properties of root project 'xxx'.
tasks - Displays the tasks runnable from root project 'xxx' (some of the displayed tasks may belong to subprojects).
Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.
Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testReleaseUnitTest - Run unit tests for the release build.
To see all tasks and more detail, run gradlew tasks --all
To see more detail about a task, run gradlew help --task <task>
BUILD SUCCESSFUL in 5m 55s
1 actionable task: 1 executed, 0 avoided (0%)
D:\AndroidStudioProjects\xxx>
最后Android Studio会弹出个对话框,当前版本用了一个不兼容Gradle插件,问我们是否升级,点“Update”,稍等一会完工!
扯了那么多,最终出场主角不过一条指令:)
gradlew tasks
1
2017-06-06更新:
刚更新Android Studio 3.0 Canary 3,又出现了上面问题,这次使用gradlew tasks再点Try Again还是不行,试了下:
gradlew tasks --all
1
再点Try Again就可以了,最后会弹出Update对话框,点击Update即可
---------------------