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.

前端 未结 15 1500
臣服心动
臣服心动 2020-12-02 05:46

I am new to Android App Development. When I tried to create a new project,Android Project...the following message popped up..

Error:Execution failed for task \':app:

15条回答
  •  一整个雨季
    2020-12-02 06:09

    Based on your screenshot i found two working solutions:

    First solution: add to dependencies of your gradle module this line

    compile 'com.android.support:support-annotations:27.1.1'
    

    and sync your project

    Note: if you are using Android studio 3+ change compile to implementation

    Second solution: Configure project-wide properties found in the documentation https://developer.android.com/studio/build/gradle-tips.html#configure-project-wide-properties

    in project gradle add this line:

    // This block encapsulates custom properties and makes them available to all
    // modules in the project.
    ext {
        // The following are only a few examples of the types of properties you can define.
        compileSdkVersion = 26
        // You can also use this to specify versions for dependencies. Having consistent
        // versions between modules can avoid behavior conflicts.
        supportLibVersion = "27.1.1"
    }
    

    Then to access this section change compileSdkVersionline to be

    compileSdkVersion rootProject.ext.compileSdkVersion

    and at dependencies section change the imported library to be like this:

    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    

    and sync your project

    Note: if you are using Android studio 3+ change compile to implementation

    For the difference between compile and implementation look at this What's the difference between implementation and compile in gradle

提交回复
热议问题