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 1523
臣服心动
臣服心动 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:05

    A better solution is explained in the official explanation. I left the answer I have given before under the horizontal line.

    According to the solution there:

    Use an external tag and write down the following code below in the top-level build.gradle file. You're going to change the version to a variable rather than a static version number.

    ext {
        compileSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    

    Change the static version numbers in your app-level build.gradle file, the one has (Module: app) near.

    android {
        compileSdkVersion rootProject.ext.compileSdkVersion // It was 26 for example
        // the below lines will stay
    }
    
    // here there are some other stuff maybe
    
    dependencies {
        implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
        // the below lines will stay
    }
    

    Sync your project and you'll get no errors.


    You don't need to add anything to Gradle scripts. Install the necessary SDKs and the problem will be solved.

    In your case, install the libraries below from Preferences > Android SDK or Tools > Android > SDK Manager

提交回复
热议问题