Gradle有错误,但它构建正常

时间:2017-03-11 09:45:59

标签: android api gradle runtime-error android-appcompat

gradle文件中出现错误,但它已构建并且从未在控制台中显示,应用程序正常运行但我认为它会在其他设备上崩溃。

enter image description here

我该如何解决?如何从工具提示中复制错误? 这是我的傻瓜:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.mol.saherproject"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        aaptOptions.cruncherEnabled = false
        aaptOptions.useNewCruncher = false
        compileOptions.encoding = 'ISO-8859-1'
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })



    compile 'com.mcxiaoke.volley:library:1.0.10'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'info.hoang8f:android-segmented:1.0.6'
    compile 'com.github.halysongoncalves:pugnotification:1.8.1'
    compile 'com.github.clans:fab:1.6.4'
    compile 'com.google.maps.android:android-maps-utils:0.3.4'
    compile 'com.android.support:multidex:1.0.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    testCompile 'junit:junit:4.12'
}

任何帮助请......

1 个答案:

答案 0 :(得分:0)

您看到此错误的原因是您的应用的依赖关系图包含不同版本的支持库。虽然build.gradle文件仅声明25.1.1,但其他依赖项之一依赖于支持库版本24.0.0。在命令行中运行以下命令以查看该依赖项的来源:

./gradlew -q dependencies

分析输出并记录com.android.support:appcompat-v7:24.0.0(或任何其他版本为24.0.0的支持库)的出现情况。依赖关系图可以很容易地将此​​依赖关系跟踪到项依赖项的根依赖项。

要解决此问题,请从使用它的模块中排除传递依赖项。例如,如果com.github.clans:fab:1.6.4依赖com.android.support:appcompat-v7:24.0.0,您就会将声明更改为:

compile('com.github.clans:fab:1.6.4') {
  exclude group: 'com.android.support'
}

然后,您必须确保项目中存在正确版本的appcompat-v7

此外,您可能希望向声明旧支持库依赖项的库的GitHub项目提交问题,或者提交更新版本的拉取请求。