赞
踩
AndroidStudio的项目在build时出现下面的报错:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project ‘TestApp’.
Could not resolve all files for configuration ‘:classpath’.
Could not resolve com.android.tools.build:gradle:7.4.0-alpha10.
Required by:
project : > com.android.application:com.android.application.gradle.plugin:7.4.0-alpha10
project : > com.android.library:com.android.library.gradle.plugin:7.4.0-alpha10
No matching variant of com.android.tools.build:gradle:7.4.0-alpha10 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘7.5’ but:
- Variant ‘apiElements’ capability com.android.tools.build:gradle:7.4.0-alpha10 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
- Variant ‘javadocElements’ capability com.android.tools.build:gradle:7.4.0-alpha10 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn’t say anything about its target Java version (required compatibility with Java 8)
- Doesn’t say anything about its elements (required them packaged as a jar)
- Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
- Variant ‘runtimeElements’ capability com.android.tools.build:gradle:7.4.0-alpha10 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)
- Variant ‘sourcesElements’ capability com.android.tools.build:gradle:7.4.0-alpha10 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn’t say anything about its target Java version (required compatibility with Java 8)
- Doesn’t say anything about its elements (required them packaged as a jar)
- Doesn’t say anything about org.gradle.plugin.api-version (required ‘7.5’)Try:
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
新版本的AndroidStudio出现下面的错误通知:
此为Android Studio默认的JDK版本与项目配置的Gradle所需的JDK不一致导致冲突所致。要求选择同一版本的JDK。
在弹出的错误通知中,选择 Select the Gradle JDK location
弹出Gradle设置,将默认的JDK改为和项目一样的版本。
或者进入Preferences->Build,Execution,Deployment->Build Tools->Gradle中,将Gradle user home和项目的Gradle JDK改为一样的版本目录。
Mac上无法选择 /Applications/Android Studio Preview.app 下的目录,可以直接输入 /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home 在应用程序中的具体地址。
修改的JDK版本按项目要求来设置,有些需要JDK8以上(required compatibility with Java 8)则选择JDK8以上版本。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。