About the Android studio Error: Execution failed for task’: app: preDebug Android Test Build’.

About the Android studio Error: Execution failed for task’: app: preDebug Android Test Build’.

Android studio will open the following errors in the build process.

  1. Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’.
  2. > 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.

Referring to the online solution:

build->Rebuid-project

After the re build, the problem was solved. But every time a new file is created or AS is restarted, this situation can be solved, but it is not thorough. So we looked for the root cause of the mistake. Read carefully and find problems.

Resolved versions for app (26.1.0) and test app (27.1.1) differ

So I looked at the build. grade file under app and found that there was no error compileSdkVersion was 26, but I didn’t find version 27.1.1 com. android. support: support – annoTations. But the above information is obviously a version conflict, so look for it in external library.

compileSdkVersion For 26), rebuild solved the problem. However, problems will be rediscovered after restarting. So the Internet continued to find ways. After trying a lot of methods, we found a way to solve the problem. The solutions are as follows:

Add the following code to dependences {} in the build.gradle file under app,

  1. androidTestCompile(‘com.android.support:support-annotations:26.1.0’) {
  2. force = true
  3. }

The structure is similar after adding dependences.

  1. dependencies {
  2. androidTestCompile(‘com.android.support:support-annotations:26.1.0’) {
  3. force = true
  4. }
  5. }

Last modified time 2018.5.9

Leave a Reply

Your email address will not be published. Required fields are marked *