#進(jìn)度:《第一行代碼》第二章,關(guān)于新建一個(gè)活動(dòng)(Activity)。
在新建布局文件的時(shí)候,頁(yè)面顯示:
design?editor?is?unavailable?until?a?successful?build(設(shè)計(jì)編輯器不可用,直到成功創(chuàng)建。)
細(xì)看下面還有一行錯(cuò)誤:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.(':app:preDebugAndroidTestBuild'任務(wù)執(zhí)行失?。?/p>
> 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'.項(xiàng)目中的?'com.android.support:support-annotations' 有沖突,應(yīng)用是26.1.0,測(cè)試應(yīng)用是27.1.1。)
解決方法:
在build.gradle的文件中加入兩行代碼:
implementation'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation'com.android.support:support-annotations:27.1.1'
同時(shí)更正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"
? ? }