2017-03-11 48 views
0

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

enter image description here

如何解决呢?我怎样才能从工具提示中复制错误? 这里是我的gradle产出:

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' 
} 

任何帮助,请......

回答

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项目提交问题,或者提交更新版本的拉取请求。