[Android studio intellisense更改API级别后显示错误

问题描述 投票:0回答:2

我是Android开发的新手,从一个老同事那里继承了一个项目。在某个时间点,我更改了项目结构中的某些内容,现在intellisense显示了所有类型的错误:例如。在import android.content.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.tigit.digicontact"
        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'
android android-studio
2个回答
0
投票

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


0
投票

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

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

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

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

这是您可以尝试的所有方法。快乐编码

© www.soinside.com 2019 - 2024. All rights reserved.