android - 构建完成并运行,但在类android上显示错误

标签 android gradle android-appcompat

我在android studio上遇到一些奇怪的错误/错误,我的应用程序gradle已完成并且在设备上流畅运行,但是它显示的错误(例如我的库)并未完全包含在android studio上,我已经这样做了

  • 清理然后重建
  • 使缓存无效并重新启动

  • 但是没有用,这是屏幕截图
    Error importing and everything who use the class

    Success gradle

    这是我的应用程式 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
    }
    

    因此,我可以运行我的应用程序,可以使用它,但是它确实使我难以编写代码,因为我无法在各处使用关于错误库和红色标记的自动完成功能。

    谢谢..

    最佳答案

  • 删除这些行,然后从正确/兼容的软件包中重新导入它们。
  • 尝试删除所有依赖项,然后进行同步,然后再次添加所有依赖项,然后进行同步。

  • 正如您在comments nimi0112Ali Ahmed's中提到的那样,您的回答确实对我有很大帮助。

    关于android - 构建完成并运行,但在类android上显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53553341/

    相关文章:

    gradle - 本地类导入问题-Gradle

    android - AppCompat - Spinner 无法在relativelayout 中工作

    android studio 不下载源代码和 javadoc

    android - 使用自定义 HTML 和预定义的基本 URL 将 CSS 文件从 Assets 加载到 WebView

    java - Gradle多项目-在项目之间共享源代码

    android - 如何在 Eclipse 中更改应用程序主题

    android - 以编程方式为支持向量着色

    android - 我需要一种从线程获取数据到另一个 Activity 的好方法

    带有乱码 UTF-8 字符的 Android WebView。

    gradle - 不正确的 liferay-plugins 依赖