Android 与gradle常见相关问题及解答(2)
来源:互联网 发布:windows调整字体大小 编辑:程序博客网 时间:2024/06/05 10:24
4.gradle隐藏包冲突问题解决
在编译一个android项目时遇到如下问题。
Warning:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.0.0) and test app (25.4.0) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
build.gradle依赖部分如下
compile fileTree(dir: 'libs', include: ['*.jar'])compile 'com.android.support:appcompat-v7:26.0.0'compile 'com.android.support.constraint:constraint-layout:1.0.2'testCompile 'junit:junit:4.12'androidTestCompile 'com.android.support.test:runner:1.0.0'androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
这就奇怪了,哪里都找不到25.4.0 这个数字,那么编译时的冲突时怎么产生的
我们进入提示的网页 http://g.co/androidstudio/app-test-app-conflict
Resolving conflicts between main and test APK
When instrumentation tests are run, both the main APK and test APK share the same classpath. Gradle build will fail if the main APK and the test APK use the same library (e.g. Guava) but in different versions. If gradle didn't catch that, your app could behave differently during tests and during normal run (including crashing in one of the cases).To make the build succeed, just make sure both APKs use the same version. If the error is about an indirect dependency (a library you didn't mention in your build.gradle), just add a dependency for the newer version to the configuration ("compile" or "androidTestCompile") that needs it. You can also use Gradle's resolution strategy mechanism. You can inspect the dependency tree by running./gradlew :app:dependencies
and ./gradlew :app:androidDependencies.看来问题找到了,runner:1.0.0 引用了25.4.0导致的。。。按照上面英文说明修改如下dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:26.0.0' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test:runner:1.0.0' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidTestCompile 'com.android.support:support-annotations:26.0.0'}加上最后一行的红色代码后,问题解决。
总结:这种问题知道原因后很简单,但是如果没有思路的话,有时候就会很困惑:到底哪里冒出来了个25.4.0?
阅读全文
0 0
- Android 与gradle常见相关问题及解答(2)
- Android 与gradle常见相关问题及解答(1)
- Android 与gradle常见相关问题及解答(3)
- gradle的相关版本及常见错误问题
- BW问题及相关解答
- cloudsim相关疑问与解答(2)
- Android Studio Gradle相关问题
- SIP常见的问题与解答
- SIP常见的问题与解答
- SIP常见的问题与解答
- servlet中常见的问题与解答
- C++新手常见的问题与解答
- USB传输协议及8个usb相关问题与解答
- Android Studio Gradle配置相关问题
- 常见的人事面试问题及参考解答
- C/C++几个面试常见细节问题及解答
- 做百度优化常见的十个问题及解答
- Android studio项目结构与Gradle相关
- Android Studio无法识别genymotion 模拟器
- xmodem 协议
- Android SDK Manager 更新代理配置
- 如何理解Redis集群的Slot映射
- Link属性 -VS2013版
- Android 与gradle常见相关问题及解答(2)
- 位运算符可能会出现的笔试题目
- hdu4843 [noi2000] 古城之谜 (Trie+dp)
- [POJ](2975)Nim ---Nim博弈(博弈)
- ReentrantLock的使用
- switch语句的应用
- MongoCollection::find 内存泄漏以及规实例
- python报错:local variable 'xxxx' referenced before assignment
- 如何快速掌握阿里巴巴内部高效测试流程?