在Android版本上找不到androidTestCompile

时间:2016-12-30 16:51:12

标签: java android mobile intellij-idea

继续another question,已解决。

我正在通过Pluralsight的Start Developing for Android课程。我们即将添加测试。说明说要将androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'添加到build.gradle文件(app模块中的文件)。

apply plugin: 'com.android.application'

android {
  compileSdkVersion 24
  buildToolsVersion '24.0.3'

  defaultConfig {
    applicationId 'com.sqisland.android.hello'
    minSdkVersion 1
    targetSdkVersion 24
    versionCode 1
    versionName '1.0.0'
  }

  dependencies {
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
  }
}

当我同步构建时,我可能会出错:

Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] F:\BanksySan\Development\PluralSight\android-hello-world\app\build\intermediates\exploded-aar\com.android.support.test.espresso\espresso-core\2.2.2\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage

我应该使用建议的修复程序吗?目前,我认为我更有可能在某个地方错过了一个图书馆。

在Andy的建议下面

我已将块移到外面,错误是:

Error:Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 8 declared in library [com.android.support.test.espresso:espresso-core:2.2.2] F:\BanksySan\Development\PluralSight\android-hello-world\app\build\intermediates\exploded-aar\com.android.support.test.espresso\espresso-core\2.2.2\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="android.support.test.espresso" to force usage

1 个答案:

答案 0 :(得分:1)

dependencies阻止移出android阻止,并将minSdkVersion提升至至少8

android {  
   minSdkVersion: 8  
   //... 
}

dependencies {   
   // .... 
}