4

help me, my Android cannot resolve symbol R( the R becomes red color) but when i try to build project, it succeed. anybody know why ? i already try clean project, rebuild project, sync project with gradle files and also invalidate cache and restart but still cannot resolve R

here is my gradle (app):

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.justinjunias.stockitem"
        minSdkVersion 24
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

apply plugin: 'com.google.gms.google-services'
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    // Butterknife
    implementation 'com.jakewharton:butterknife:8.6.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'

    //Design
    implementation 'com.android.support:design:28.0.0'
    //Volley
    implementation 'com.android.volley:volley:1.1.1'
    //Firebase
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.0.6'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-firestore:18.1.0'
}

And my gradle build:

// 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:3.3.2'
        //Firebase
        classpath 'com.google.gms:google-services:4.2.0'


        // 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
}

1 Answers1

3

Option 1: Update Android Studio to 3.3

Option 2: Update Gradle Version in Project Level build.gradle

classpath 'com.android.tools.build:gradle:3.2.1'

Option 3: Take into account the following IDE functionalities:

Sync Project with gradle files

Build -> Clean Project

Build -> Rebuild Project

File -> Invalidate caches

VIISHRUT MAVANII
  • 11,410
  • 7
  • 34
  • 49