Android构建成功,但无法解决R

时间:2019-03-25 02:31:53

标签: android

帮帮我,我的Android无法解析符号R(R变为红色),但是当我尝试构建项目时,它会成功。有人知道为什么吗?我已经尝试过清理项目,重建项目,使用gradle文件同步项目,并使缓存无效并重新启动,但仍然无法解析R

这是我的gradle(应用程序):

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

我的gradle版本:

// 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 个答案:

答案 0 :(得分:3)

选项1:将Android Studio更新到3.3

选项2:在项目级别library(tidyverse) df %>% replace_na(list(mth_yr = "Pending")) %>% ggplot(aes(x = factor(mth_yr, levels = c("Jul2018", "Aug2018", "Sep2018", "Oct2018", "Nov2018","Dec2018", "Pending")), y = output)) + geom_col() + xlab("")

更新Gradle版本
build.gradle

选项3::请考虑以下IDE功能:

使用gradle文件同步项目

构建->清理项目

构建->重建项目

文件->使缓存无效