尝试运行Android项目时出现以下错误。
如果我使用tools:replace="allowBackup,supportsRtl"
,那么截面形成的场景如下: -
Here is the error details screenshot
Here is the error showing in the merged manifest file
但如果我使用工具:replace =“android:value”那么合并清单文件中会出现以下错误: -
The above is the error in merged manifest file and the bottom is the general error shown.
以下是我的Gradle文件: -
以下是应用级Gradle文件: -
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.android.todolist"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
dataBinding.enabled = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0'
//add Recycler view dependencies; must match SDK version
compile 'com.android.support:recyclerview-v7:25.4.0'
//FAB dependencies
compile 'com.android.support:design:25.4.0'
implementation 'com.google.gms:google-services:3.2.0'
//Testing
// Instrumentation dependencies use androidTestCompile
// (as opposed to testCompile for local unit tests run in the JVM)
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:27.1.1'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
}
这是项目级Gradle文件: -
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they
belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的Android Studio版本是3.1.2。我试过清洁&多次重建项目。我也试过使缓存无效,但没有任何帮助。我不认为通过执行前两行中提到的任务可以纠正这个错误。
任何帮助将不胜感激。 提前谢谢。
答案 0 :(得分:1)
首先,您需要让compileSdkVersion
,buildToolsVersion
和targetSdkVersion
使用相同的版本。使用版本27.因此,将 app build.gradle更改为:
apply plugin:'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.android.todolist"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
// ... redacted
然后,您需要使用支持库版本27作为依赖项。因此,将依赖项块中的支持库更改为:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.1.0'
//add Recycler view dependencies; must match SDK version
compile 'com.android.support:recyclerview-v7:27.1.1'
//FAB dependencies
compile 'com.android.support:design:27.1.1'
implementation 'com.google.gms:google-services:3.2.0'
//Testing
// Instrumentation dependencies use androidTestCompile
// (as opposed to testCompile for local unit tests run in the JVM)
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:27.1.1'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
}
然后删除依赖项块中的以下行:
implementation 'com.google.gms:google-services:3.2.0'
因为它不是您的依赖项,但它应该作为类路径放在 root build.gradle
。
这里你的root build.gradle应该是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they
belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}