同步时出现分级问题。应用级 gradle 文件
清单.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aparna.search_recy">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.aparna.search_recy"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:26.0.2'
}
错误:
Error:Execution failed for task ':app:processDebugManifest'.
清单合并失败:属性元数据# Android . support . version @ value value =(26 . 1 . 0)来自[com . Android . support:support-v 13:26 . 1 . 0]Android manifest . XML:28:13-35也存在于[com . Android . support:card view-v 7:26 . 0 . 2]Android manifest . XML:25:13-35 value =(26 . 0 . 2)。建议:将“tools:replace="android:value "”添加到AndroidManifest.xml:26:9-28:38处的元素中以进行覆盖。
首先,您可以在< code>compileSdkVersion下面添加缺少的< code>buildToolVersion,然后使用同样缺少的< code > compile ' com . Android . support:recycler view-V7:版本,因此在代码下面添加此检查
android {
compileSdkVersion 26
buildToolsVersion "26.0.1" //change here
defaultConfig {
applicationId "com.aparna.search_recy"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:recyclerview-v7:26.1.0' //change here
compile 'com.android.support:cardview-v7:26.1.0'
}
如果这不起作用,最后清理并重建项目转到文件-
实际上,如果您在依赖项中使用不同的不同版本,就会出现此错误。
要避免此错误,您只需要将 cardview-v7:26.0.2 版本更改为 26.1.0。
它会解决你的问题
将您的< code>cardview-v7:26.0.2版本更改为26.1.0