首页 > 解决方案 > 如何使用 Firebase 修复 Android Studio 自动完成?

问题描述

我正在将 Android Studio 设置为使用 Firebase,但是在设置之后,Android Studio 自动完成不会显示例如(DatabaseReference)。我按照谷歌的建议设置一切。出了什么问题?

看图片:

Firebase 配置

在此处输入图像描述

安卓工作室

在此处输入图像描述

我的项目摇篮:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
}
dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"
        classpath "com.google.gms:google-services:4.3.4"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
      }
  }

  allprojects {
      repositories {
          google()
          jcenter()
      }
  }

  task clean(type: Delete) {
     delete rootProject.buildDir
  }

我的应用程序摇篮:

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.firebase"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation platform('com.google.firebase:firebase-bom:26.0.0')
    implementation 'com.google.firebase:firebase-analytics'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

谢谢你

标签: firebaseandroid-studio

解决方案


1.关闭Android studio然后进入android studio所在的文件夹或者你可以去

驱动器 C -> 用户 -> 找到 .gradle 文件并执行以下操作

查找 .gradle 文件 -> 在 .gradle 文件夹中删除缓存文件夹,然后重新启动 android studio 将您的文件与 gradle 同步。


推荐阅读