Error:Execution failed for task ':app:preDebugAndroidTestBuild'.錯誤解決

在新建佈局文件的時候,頁面顯示:html

design editor is unavailable until a successful build(設計編輯器不可用,直到成功建立。)android

細看下面還有一行錯誤:app

Error:Execution failed for task ':app:preDebugAndroidTestBuild'.(':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.佈局

( ':app'.項目中的 'com.android.support:support-annotations' 有衝突,應用是26.1.0,測試應用是27.1.1。)測試

解決方法:gradle

在build.gradle的文件中加入兩行代碼:ui

implementation'com.android.support:appcompat-v7:27.1.1'spa

androidTestImplementation'com.android.support:support-annotations:27.1.1'設計

同時更正build.gradle中的compileSdkVersion和targetSdkVersion版本爲27:

android {

compileSdkVersion27

    defaultConfig {

applicationId"com.example.culif.activitytest"

        minSdkVersion27

        targetSdkVersion27

        versionCode1

        versionName"1.0"

        testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"

    }

 

若是出現找不到27.1.1的錯誤點一下install就能夠 做者:西柚讀書 連接:https://www.jianshu.com/p/efbc0a23d942 來源:簡書 簡書著做權歸做者全部,任何形式的轉載都請聯繫做者得到受權並註明出處。
相關文章
相關標籤/搜索