Android studio intellisense无法在导入时解析符号

时间:2019-12-27 07:56:47

标签: android android-studio

我是Android开发的新手,并且从一个老同事那里继承了一个项目。在某个时候,我更改了项目结构。我不确定我所做的更改是否触发了这些错误。但是,现在intellisense显示了所有类型的错误:例如。在import android.content.Intent;上显示无法解析符号'Intent'

现在,该项目仍然可以正常构建和运行,但是,项目中到处都是弯曲的红色线条,自动完成功能不起作用。

我已尽力解决此问题(使缓存无效/删除文件/重新导入项目等),我发现唯一起作用的方法是将API版本更改为27,在这种情况下,虽然所有智能提示都消失了,项目中断,因为它使用版本28的东西。 enter image description here

当前,该应用模块具有compileSdkVersion 28和targetSdkVerion27。将两者都更改为27可以解决智能问题,但会破坏项目,将两者都更改为28(或29)都无法解决任何问题。

感觉我可能需要更新其他内容?

*根据haresh的要求进行更新,*

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "nl.app.ofme"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        ndk {
            abiFilters "armeabi", "armeabi-v7a"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion = '28.0.3'

//Used to get clear warning details about deprecated methods
    allprojects {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')

        implementation 'com.android.support:appcompat-v7:28.1.2'
        implementation 'com.android.support:design:28.0.0'

        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'com.squareup.okio:okio:1.15.0'
        implementation 'com.squareup.okhttp3:okhttp:3.11.0'

        implementation 'com.android.volley:volley:1.1.0@aar'
        implementation 'com.google.firebase:firebase-analytics:17.2.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-messaging:20.0.1'
}
apply plugin: 'com.google.gms.google-services'

2 个答案:

答案 0 :(得分:0)

在Android Studio中,转到“文件”->“使缓存无效/重新启动...

答案 1 :(得分:0)

  1. 尝试对所有模块和项目级别库使用更新的版本。

  2. 文件->具有gradle文件的Snyc项目。

  3. 使用androidx迁移。重构->迁移到Android

  4. 在Android Studio中,转到“文件”->“使缓存无效/重新启动”

这是您可以尝试的所有东西。