我刚刚将Android Studio更新到最新版本2.2.2。之后需要更新gradle.But更新后我无法运行以前运行良好的项目。
以下是gradle log错误: -
警告:警告:依赖关系xpp3:xpp3:1.1.4c将被忽略 productionDebug因为它可能与内部版本冲突 由Android提供。
警告:警告:依赖关系xpp3:xpp3:1.1.4c将被忽略 productionRelease因为它可能与内部版本冲突 由Android提供。
警告:警告:依赖关系xpp3:xpp3:1.1.4c将被忽略 stagingDebug因为它可能与内部版本冲突 由Android提供。
警告:警告:依赖关系xpp3:xpp3:1.1.4c将被忽略 stagingRelease因为它可能与内部版本冲突 由Android提供。
警告:与依赖性冲突 ' com.android.support:recyclerview-V7&#39 ;.已解决的应用版本 (23.0.0)和测试应用程序(21.0.3)不同。看到 http://g.co/androidstudio/app-test-app-conflict了解详情。
警告:与依赖项冲突&com.android.support:support-v4'。 app(25.0.0)和测试app(21.0.3)的已解决版本有所不同。看到 http://g.co/androidstudio/app-test-app-conflict了解详情。
警告:与依赖性冲突 ' com.android.support:recyclerview-V7&#39 ;.已解决的应用版本 (23.0.0)和测试应用程序(21.0.3)不同。看到 http://g.co/androidstudio/app-test-app-conflict了解详情。
警告:与依赖项冲突&com.android.support:support-v4'。 app(25.0.0)和测试app(21.0.3)的已解决版本有所不同。看到 http://g.co/androidstudio/app-test-app-conflict了解详情。
错误:任务执行失败 ':app:prepareStagingDebugAndroidTestDependencies'。依赖性错误。有关详细信息,请参阅控制台。
而Heres是我的Build.gradle文件供参考: -
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.gms.google-services'
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'LICENSE.txt'
}
compileSdkVersion 23
buildToolsVersion '22.0.1'
defaultConfig {
multiDexEnabled true
applicationId 'com.qa.app'
minSdkVersion 15
targetSdkVersion 21
versionCode 28
versionName '3.5'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
productFlavors {
production {
minSdkVersion 15
targetSdkVersion 21
versionCode 28
versionName '3.5'
signingConfig signingConfigs.config
}
staging {
minSdkVersion 15
targetSdkVersion 21
versionCode 28
versionName '3.5'
signingConfig signingConfigs.config
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:cardview-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.android.support:design:22.2.1'
compile 'com.facebook.rebound:rebound:0.3.7'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:notifications:1.0.2'
// compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@aar'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.android.support:support-annotations:25.0.0'
// compile 'com.google.android.gms:play-services:7.5.0'
compile project(':library')
androidTestCompile 'com.android.support:support-annotations:25.0.0'
// androidTestCompile 'com.android.support:support-annotations:22.2.1'
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.0'
compile project(':rate-me')
compile project(':volleyNew')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile('com.paypal.sdk:paypal-android-sdk:2.15.0') {
exclude group: 'io.card'
}
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0'
compile 'org.igniterealtime.smack:smack-experimental:4.1.0'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0'
compile 'org.igniterealtime.smack:smack-im:4.1.0'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.android.support:multidex:1.0.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
}
答案 0 :(得分:2)
在您的情况下,解决方案应该是将以下行添加到依赖项:
androidTestCompile 'com.android.support:recyclerview-v7:25.0.0'
androidTestCompile 'com.android.support:support-v4:25.0.0'
此外,您应该对齐支持库版本。 在您的情况下,所有这些都应 25.0.0
以下是类似的问题:Resolved versions for app (22.0.0) and test app (21.0.3) differ
<强>更新强> 为了使依赖控制更容易,您可以定义变量,您可以在其中存储当前支持库版本。
因此,您的依赖块应该如下:
def support_version = '25.0.0'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/YouTubeAndroidPlayerApi.jar')
// support libraries that should have the same version
compile "com.android.support:appcompat-v7:$support_version"
compile "com.android.support:cardview-v7:$support_version"
compile "com.android.support:support-v4:$support_version"
compile "com.android.support:recyclerview-v7:$support_version"
compile "com.android.support:support-annotations:$support_version"
compile "com.android.support:design:$support_version"
compile project(':library')
compile project(':rate-me')
compile project(':volleyNew')
compile 'com.facebook.rebound:rebound:0.3.7'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:notifications:1.0.2'
compile 'com.google.android.gms:play-services:9.6.1'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@aar'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0'
compile 'org.igniterealtime.smack:smack-experimental:4.1.0'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0'
compile 'org.igniterealtime.smack:smack-im:4.1.0'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.android.support:multidex:1.0.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
compile('com.paypal.sdk:paypal-android-sdk:2.15.0') {
exclude group: 'io.card'
}
androidTestCompile "com.android.support:recyclerview-v7:$support_version"
androidTestCompile "com.android.support:support-v4:$support_version"
androidTestCompile "com.android.support:support-annotations:$support_version"
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.0'
}