【问题标题】:Build complete and running but showing error on class android构建完成并运行,但在类 android 上显示错误
【发布时间】:2018-11-30 07:49:22
【问题描述】:

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

  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
}

所以我可以运行我的应用程序,我可以使用它,但它对我来说真的很烦人,因为我不能使用自动完成来处理错误库和到处的红色标记。

谢谢你..

【问题讨论】:

  • 删除那些显示错误的语句并重新导入。
  • 尝试删除所有依赖项然后同步再次添加所有依赖项然后同步
  • @nimi0112 和 AliAhmed 非常感谢您,它成功了。你们都为我节省了很多时间:)

标签: android gradle android-appcompat


【解决方案1】:
  1. 删除这些行并从正确/兼容的包中重新导入它们。
  2. 尝试删除所有依赖项然后同步并再次添加所有依赖项然后同步。

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

【讨论】:

    猜你喜欢
    • 2014-09-01
    • 2021-01-21
    • 2022-10-05
    • 1970-01-01
    • 2016-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多