所以我安装了android studio 3.0.1,并在打开gradle后立即显示以下错误。我尝试添加设计和支持等依赖项,但是徒劳无功。有人能帮助我吗?先感谢您。
它显示找不到某些属性,如dialogCornerRadius和fontVariation设置。
由于compileSdkVersion
和库版本不匹配而发生此错误。
例如:
compileSdkVersion 27
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
并且还避免在库中使用+符号,如下所示:
implementation 'com.android.support:appcompat-v7:26.+'
使用像这样的精确库版本
implementation 'com.android.support:appcompat-v7:26.1.0'
在库中使用+符号会使构建过程难以收集所需的确切版本,从而使系统不稳定,因此应该不鼓励。
在我的情况下,这个错误发生在我使用的时候
compileSdkVersion 28
图书馆和护目镜
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
}
图书馆。如果您的项目中出现这种情况,我强烈建议您从项目中完全删除Google材料组件库。
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.android.support:design:+'
并设置依赖项:
implementation 'com.google.android.material:material-components:+'
如果您为AndroidX迁移并出现此错误,则需要将compile SDK设置为Android 9.0(API级别28)或更高级别
我有完全相同的问题。以下主题帮助我解决了这个问题。只需将您的Compile SDK版本设置为Android P.
https://stackoverflow.com/a/49172361/1542720
我选择了修复此问题:
API 27+:Android API 27,P预览(预览)
在项目结构设置中。下图显示了我的设置。构建应用程序时出现的13个错误已经消失。
检查您的依赖项以了解版本中+
的用法。一些依赖可能是使用com.android.support:appcompat-v7:+
。当新版本发布并且可能破坏功能时,这会导致问题。
对此的解决方案是使用com.android.support:appcompat-v7:{compileSdkVersion}.+
或者根本不使用+
并使用完整版本(例如com.android.support:appcompat-v7:26.1.0
)。
如果你在build.gradle文件中看不到这一行,请在android studio终端中运行,以概述每个依赖项使用的内容
gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
(包括androidtest依赖项)
要么
gradlew -q dependencies app:dependencies --configuration debugCompileClasspath
(调试的常规依赖项)
这导致了一些看起来很接近的东西
------------------------------------------------------------
Project :app
------------------------------------------------------------
debugCompileClasspath - Resolved configuration for compilation for variant: debug
...
+--- com.android.support:appcompat-v7:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-v4:26.1.0 (*)
| +--- com.android.support:support-vector-drawable:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | \--- com.android.support:support-compat:26.1.0 (*)
| \--- com.android.support:animated-vector-drawable:26.1.0
| +--- com.android.support:support-vector-drawable:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support:design:26.1.0
| +--- com.android.support:support-v4:26.1.0 (*)
| +--- com.android.support:appcompat-v7:26.1.0 (*)
| +--- com.android.support:recyclerview-v7:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | \--- com.android.support:support-core-ui:26.1.0 (*)
| \--- com.android.support:transition:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| \--- com.android.support:support-v4:26.1.0 (*)
+--- com.android.support.constraint:constraint-layout:1.0.2
| \--- com.android.support.constraint:constraint-layout-solver:1.0.2
(*) - dependencies omitted (listed previously)
如果您无法控制更改版本,请尝试强制使用特定版本。
configurations.all {
resolutionStrategy {
force "com.android.support:appcompat-v7:26.1.0"
force "com.android.support:support-v4:26.1.0"
}
}
根据设置为28.0.0的内容,力依赖性可能需要不同
这是因为compileSdkVersion,buildToolsVersion和Dependencies实现不匹配你必须这样做我有28个库然后
compileSdkVersion 28
targetSdkVersion 28
buildToolsVersion 28.0.3
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
如果我们使用任何小于28的地方,则应该发生此错误,请尝试匹配库。
也许现在为时已晚,但我找到了一个解决方案:
你必须在qazxsw poi中编辑qazxsw poi - >到最新版本(现在它是28)。像那样:
build.gradle
或者您可以更改实施版本:
compileSdkVersion
我在添加mapbox导航API时遇到了同样的问题并通过转到:file> project Structure解决了这个问题,然后将compile sdk版本和构建工具版本设置为最新版本。这是截图:android {
compileSdkVersion 28
defaultConfig {
applicationId "NAME_OF_YOUR_PROJECT_DIRECTORY"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
希望能帮助到你。
尝试将compileSdkVersion更改为:dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
api 'com.android.support:design:27.+'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
找到一个简洁的插件来解决这个问题:cordova-android-support-gradle-release
cordova插件添加cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION = 27. + --save