Android Studio 运行 应用存在编译时错误

Android Studio running app with compile time errors

今天我在 Android Studio IDE.

中遇到了一个奇怪的问题

您可以看到我没有添加 RecyclerViewSupport-v4 的依赖项,并且 类 显示错误。现在好了。但问题是我能够 运行 项目,我的应用程序在移动设备中 运行ning,gradle 不显示有关 类 的错误。

我不希望 Android Studio 有这种行为。

可以看到我没有添加RecyclerView依赖

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':Baselib')
    implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VER"
    implementation "com.android.support:design:$SUPPORT_LIB_VER"
    implementation "com.google.code.gson:gson:2.7"
    implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VER"
    implementation "com.squareup.retrofit2:retrofit:${RETROFIT_VER}"
    implementation "com.squareup.retrofit2:converter-gson:${RETROFIT_VER}"
    implementation "com.jakewharton:butterknife:$BUTTER_KNIFE_VER"
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VER"
    implementation "com.intuit.sdp:sdp-android:$SDP_VERSION"
    implementation "com.intuit.ssp:ssp-android:$SDP_VERSION"
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'
}

现在看看 Android Studio 的神奇之处

这是 Android Studio 的新功能,它的 gradle 构建成功但出现编译时错误?不!!!

我已经试过了:

我这样做了并且成功了。

  • 删除构建文件夹
  • 关闭项目
  • File>New>Import Project导入项目(而不是打开

现在我得到了预期的所有错误。

以下对我有用:

  1. 删除 .idea 个文件夹
  2. 清理 + 重建