Android Studio Gradle生成问题(无法运行项目)
我刚刚将我的Android Studio更新为最新版本2.2.2。之后需要更新gradle。但在更新了这两个版本后,我无法运行以前运行得很好的项目 下面是渐变日志错误:- 警告:警告:忽略的依赖项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'。已解析应用程序的版本 (23.0.0)和测试应用程序(21.0.3)有所不同。看见 详情请参阅 警告:与依赖项“com.android.support:support-v4”冲突。 应用程序(25.0.0)和测试应用程序(21.0.3)的解析版本不同。看见 详情请参阅 警告:与依赖项冲突 'com.android.support:recyclerview-v7'。已解析应用程序的版本 (23.0.0)和测试应用程序(21.0.3)有所不同。看见 详情请参阅 警告:与依赖项“com.android.support:support-v4”冲突。 应用程序(25.0.0)和测试应用程序(21.0.3)的解析版本不同。看见 详情请参阅 错误:任务执行失败 ':应用程序:PrepareStatingDebuggeandRoidTestDependencies'。依赖项错误。有关详细信息,请参阅控制台。 这是我的Build.gradle文件供参考:-Android Studio Gradle生成问题(无法运行项目),android,android-studio,android-gradle-plugin,Android,Android Studio,Android Gradle Plugin,我刚刚将我的Android Studio更新为最新版本2.2.2。之后需要更新gradle。但在更新了这两个版本后,我无法运行以前运行得很好的项目 下面是渐变日志错误:- 警告:警告:忽略的依赖项xpp3:xpp3:1.1.4c productionDebug,因为它可能与内部版本冲突 由Android提供 警告:警告:忽略的依赖项xpp3:xpp3:1.1.4c productionRelease,因为它可能与内部版本冲突 由Android提供 警告:警告:忽略的依赖项xpp3:xpp3:1.
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;
}
}
在您的情况下,解决方案应该是向依赖项添加以下行:
androidTestCompile 'com.android.support:recyclerview-v7:25.0.0'
androidTestCompile 'com.android.support:support-v4:25.0.0'
此外,还应调整支持库版本。
在您的情况下,它们都应该25.0.0
这里有一个类似的问题:
更新:
为了使依赖关系控制更容易,您可以定义一个变量,用于存储当前版本的支持库
因此,依赖项块应如下所示:
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'
}
阅读更多:,@vishnumm93这是个坏建议。您应该解决版本冲突,而不是避免。@Anil检查此解决方案我在上面添加了两行,但结果与上面相同。因此,我还需要将支持版本更改为25.0。0@Anil我已经更新了答案。在重建您的项目之后,所以我认为我们必须保持依赖项和测试依赖项相同,对吗?@Anil还
编译文件('libs/YouTubeAndroidPlayerApi.jar')
是多余的,因为YouTubeAndroidPlayerApi.jar已经添加到这一行:编译文件树(dir:'libs',include:['*.jar])