构建完成 运行 但在 class android 上显示错误

Build complete and running but showing error on class android

我在 android studio 上有一些奇怪的错误/错误,我的应用程序 gradle 已完成并且 运行 在设备上顺利运行,但它显示错误,例如我的库未完全包含在 android 工作室,我已经

  1. 清理然后重建
  2. 使缓存无效并重新启动

但没有任何效果,这是屏幕截图

这是我的应用程序Gradle

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
    applicationId "com.host.appname"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
    useLibrary 'org.apache.http.legacy'
    vectorDrawables.useSupportLibrary = true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        lintOptions {
            disable 'MissingTranslation'
        }
    }
}
productFlavors {
}
packagingOptions {
    exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
    exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}

这是我的项目gradle

    buildscript {
        repositories {
            jcenter()
            flatDir {
                dirs 'libs'
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
        }
    }

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

所以我可以 运行 我的应用程序,我可以使用它,但它真的让我感到不安,因为我无法使用关于错误库和红色标记的自动完成功能。

谢谢..

  1. 删除行并从 correct/compatible 包中重新导入它们。
  2. 尝试删除所有依赖项然后同步并再次添加所有依赖项然后同步。

正如您在 nimi0112 and Ali Ahmed's 中提到的,您的回答对我帮助很大。