一、报错信息
创建个新项目,运行直接报错,信息如下:
No matching variant of com.android.tools.build:gradle:
7.4.2
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:
A problem occurred configuring root project 'demo'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:7.4.2.
Required by:
project : > com.android.application:com.android.application.gradle.plugin:7.4.2
project : > com.android.library:com.android.library.gradle.plugin:7.4.2
> No matching variant of com.android.tools.build:gradle:7.4.2 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.2 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.2 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.2 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.2 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.
二、错误分析
有些问题是项目中的Gradle版本不是7.4.2,我们需要将build.gradle文件中改它为7.4.2。
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
这里明显不是,从报错信息中我们可以看到是Java 版本没跟上,需要将 Java 8 改为 Java11。
三、解决方案
OK->OK->Try Again 齐活。
An issue was found when checking AAR metadata文章浏览阅读5.4k次,点赞7次,收藏13次。Dependency androidx.activity:activity:1.8.0 必须34,那我不用就完事啦。app/build.gradle中将 compileSdk 和 targetSdk 升至 34 即可。首先找到androidx.activity:activity:1.8.0在哪?从这段信息告诉我们,升级SDK这个是必须的,除非你不用。毕竟项目不大牵扯不是很很大,而且新内容是肯定要兼容的,嘿嘿嘿。具体采取哪种方案具体问题具体分析了,个人采用了。_dependency 'androidx.activity:activity:1.8.0' requires libraries and applica
https://shuaici.blog.csdn.net/article/details/134533886
Android 12 第一次运行就报错文章浏览阅读2.2k次,点赞7次,收藏6次。Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-e_remote stack trace: at com.android.server.wm.activitytasksupervisor.checksta
https://shuaici.blog.csdn.net/article/details/120919810
A problem occurred configuring root project 'DataBinding'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:7.4.2.
Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题
No matching variant of com.android.tools.build:gradle:7.4.2 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.4.2' 怎么解决