无法在Android Studio中解析符号'annotation'?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法在Android Studio中解析符号'annotation'?相关的知识,希望对你有一定的参考价值。

我正在我的项目中使用新的androidX,我需要在代码中使用Nulllable(@Nullable),但是,当我尝试“ import android.support.annotation.Nullable;”时,此命令返回给我: “无法解析符号'注释'”。

这是我在模块级别的build.gradle:

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

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    // Implementação da autenticação com o servirdor firebase
    implementation 'com.google.firebase:firebase-auth:19.0.0'
    //Implementação da parte visual do Firebase
    implementation 'com.firebaseui:firebase-ui-auth:6.1.0'
    // Implementação de imagens arrendodas
    implementation 'de.hdodenhof:circleimageview:3.0.1'
    // Autenticação geral com o servirdor do Firebase
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    // Autenticação integrada ao google play services
    implementation 'com.google.firebase:firebase-analytics:17.2.0' // Integração ao Google Análises
    implementation 'com.google.firebase:firebase-messaging:20.0.0'
    // Integração ao sistema de notifação
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    // Integração com o banco de dados
    implementation 'com.google.firebase:firebase-firestore:21.1.1'
    implementation 'com.google.firebase:firebase-storage:19.1.0'
    implementation 'androidx.multidex:multidex:2.0.0'
    // Integração ao sistema de autenticação de usuário
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-ui:2.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.work:work-runtime:2.2.0'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'

}
apply plugin: 'com.google.gms.google-services'
答案

请勿混用android supportandroidx

对于androidx,请使用androidx.annotation.Nullable

以上是关于无法在Android Studio中解析符号'annotation'?的主要内容,如果未能解决你的问题,请参考以下文章

无法在Android Studio中解析符号'annotation'?

Android Studio 无法解析符号“TabLayout”

无法在 Android Studio 中解析符号“LocationClient”

无法解析 Android Studio 上的符号“属性”

无法解析符号 JSONObject (Android Studio)

无法在 Android Studio 2.0 中解析符号 R [重复]