我已经通过互联网搜索解决了这个问题,但我无法找到解决方案。
同步我的项目后,gradle运行时没有任何错误,但是当我打开build.gradle文件时,它通过在build.gradle(app)页面上加下划线compile 'com.android.support:appcompat-v7:25.3.1'
来显示错误。当我检查更多信息时,它显示了这一点。
这是我的完整gradle文件:
apply plugin: 'com.android.application'
android {
dexOptions {
jumboMode = true
}
signingConfigs {
config {
keyAlias 'Lagchat'
keyPassword 'HomeAlone'
storeFile file('C:/Users/WESLEY/Desktop/APKBuild/android.jks')
storePassword 'HomeAlone'
}
}
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.classics.classics"
minSdkVersion 17
targetSdkVersion 25
versionCode 10
versionName "1.0.3"
testInstrumentationRunner "android.support .test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
signingConfig signingConfigs.config
}
debug {
debuggable false
minifyEnabled false
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/rxjava.properties'
}
productFlavors {
free {
minSdkVersion 17
applicationId 'com.classics.classics'
signingConfig signingConfigs.debug
targetSdkVersion 25
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
versionCode 10
versionName '1.0.3'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//firebase
//Facebook
//others
compile project(':emoticon')
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.firebase:firebase-config:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.firebase:firebase-storage:11.0.4'
compile 'com.google.firebase:firebase-invites:11.0.4'
compile 'com.google.firebase:firebase-crash:11.0.4'
compile 'com.google.firebase:firebase-appindexing:11.0.4'
compile 'com.google.firebase:firebase-ads:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.google.android.gms:play-services-places:11.0.4'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.google.android.gms:play-services-ads:11.0.4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
这是我对build.gradle(项目)的完整文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
注意事项:
我之前使用此compileSdkVersion 25
buildToolsVersion '25.0.3'
之前将其更改为26
和26.0.1
,因为我在同步gradle时收到此错误Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
。
我该怎么做才能使这个项目运行没有任何错误。显然,即使在成功构建了gradle之后,也停止在build.gradle(app)上显示错误。
答案 0 :(得分:1)
正如您所面临的错误所说
所有com.android.support库必须使用相同的版本规范
但是你有很多这个小组的模块提到了不同的版本。
您有firebase
的依赖项,如果您运行gradle app:dependencies
,则可以看到以下依赖项树
+--- com.google.firebase:firebase-core:11.0.4
| \--- com.google.firebase:firebase-analytics:[11.0.4] -> 11.0.4
| +--- com.google.firebase:firebase-analytics-impl:[11.0.4] -> 11.0.4
| | +--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4
| | | \--- com.android.support:support-v4:25.2.0 -> 27.0.1
| | | +--- com.android.support:support-compat:27.0.1
| | | | +--- com.android.support:support-annotations:27.0.1
因此firebase引用com.android.support
版本的27.0.1
库
因此,您需要更新您的依赖项以协调您的项目。
然后改变:
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:design:26.0.1'
与
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.android.support:support-v4:27.0.1'
compile 'com.android.support:design:27.0.1'
之后,您还需要更新compileSdkVersion
更改
compileSdkVersion 26
带
compileSdkVersion 27
最后
+--- com.afollestad.material-dialogs:core:0.9.4.5
| +--- com.android.support:support-v13:25.3.1
| | +--- com.android.support:support-annotations:25.3.1 -> 27.0.1
support-v13
引用版本25.3.1
所以在你的依赖项中添加一行
compile 'com.android.support:support-v13:27.0.1'
因此,gradle的解决策略可以选择更高版本
RECAP ,您的依赖项应该以这种方式更改:
dependencies {
...
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.android.support:support-v13:27.0.1'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.android.support:support-v4:27.0.1'
compile 'com.android.support:design:27.0.1'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.firebase:firebase-config:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.firebase:firebase-storage:11.0.4'
compile 'com.google.firebase:firebase-invites:11.0.4'
compile 'com.google.firebase:firebase-crash:11.0.4'
compile 'com.google.firebase:firebase-appindexing:11.0.4'
compile 'com.google.firebase:firebase-ads:11.0.4'
...
}
别忘了compileSdkVersion 27