android - 使用 android studio 3.0.1 创建新项目时出错

标签 android

错误:任务 ':app:preDebugAndroidTestBuild' 执行失败。

Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

编辑:以下摘自评论

以下是我的依赖项:

dependencies { 
    implementation fileTree(dir: 'libs', include: ['*.jar']) 
    implementation 'com.android.support:appcompat-v7:26.1.0' 
    implementation 'com.android.support.constraint:constraint-layout:1.1.0' 
    testImplementation 'junit:junit:4.12' 
    androidTestImplementation 'com.android.support.test:runner:1.0.2' 
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 
    androidTestImplementation 'com.android.support:support-annotations:27.1.1' 
}

最佳答案

基于documentation :

Both your app APK and its test APK share the same classpath. So, you can get a build error if both APKs depend on different versions of the same library.

所以解决办法是改变你的

com.android.support:appcompat-v7:26.1.0

com.android.support:appcompat-v7:27.1.1

关于android - 使用 android studio 3.0.1 创建新项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50086012/

相关文章:

android - 如何计算在 Android 项目中作为依赖项添加的库的大小

java - 使用 AppCompatActivity 时出现 NoClassDefFoundError

android - 视频 - 使用 VideoView/MediaPlayer 或 intent.action_view 和用户的选择?

java - Intent 不在以下代码中打开

由于 java.lang.NullPointerException,Android 应用程序在启动时崩溃

Java静态类变量初始化效率

android - 如何检索在 XML 中定义的 fragment 实例?

java - Android问题加载小部件-logcat中没有错误

Android - 将用户发送到 Activity 的 GCM 推送通知不会导致 onCreate 调用

Android 在用户关闭应用程序时销毁 session