Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 升级后,我的项目找不到资源文件R,但仍在运行应用程序,未显示任何错误。如何解决_Android_Android Layout - Fatal编程技术网

Android 升级后,我的项目找不到资源文件R,但仍在运行应用程序,未显示任何错误。如何解决

Android 升级后,我的项目找不到资源文件R,但仍在运行应用程序,未显示任何错误。如何解决,android,android-layout,Android,Android Layout,我面临一个特殊的问题。我已将我的项目从23 api升级到28 api。升级后,从我的活动中,显示无法解析R,但我成功运行了其构建apk,并且应用程序运行良好,没有显示任何错误2更多的UI名称在“setContentView”中也无法识别,我已检查UI是否存在问题。如何更具体地检查UI错误(如果存在) apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion "

我面临一个特殊的问题。我已将我的项目从23 api升级到28 api。升级后,从我的活动中,显示无法解析R,但我成功运行了其构建apk,并且应用程序运行良好,没有显示任何错误2更多的UI名称在“setContentView”中也无法识别,我已检查UI是否存在问题。如何更具体地检查UI错误(如果存在)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {

        minSdkVersion 18
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
    }
    configurations {
        compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
        all*.exclude group: 'xpp3', module: 'xpp3'
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
    repositories {
        jcenter()
        maven { url "https://dl.bintray.com/hani-momanii/maven" }
    }

    aaptOptions {
        cruncherEnabled = false
    }

    lintOptions {
        checkReleaseBuilds false
        //If you want to continue even if errors found use following line
        abortOnError false
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    implementation 'com.google.gdata:core:1.47.1'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-nearby:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.markomilos:paginate:0.5.1'
    implementation 'com.github.lovetuzitong:MultiImageSelector:1.2'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'com.iarcuschin:simpleratingbar:0.1.5'
    implementation 'com.droidninja:filepicker:2.1.1'
    implementation 'com.google.android:flexbox:1.0.0'
    implementation 'com.felipecsl.asymmetricgridview:library:2.0.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'

}
apply plugin: 'com.google.gms.google-services'
build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.2.0'

    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

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

有人能帮我吗。

这个问题有几个原因,也有几个解决方案:

首先要尝试的是使缓存失效并重新启动,通常这只是Android Studio的缓存问题


如果这不起作用,您可能会遇到Gradle/Android Studio版本问题。通常在升级CompileSDK时,gradle版本也需要更新,但Android Studio会抱怨您遇到的错误(我已经遇到过)。同时将您的Android Studio更新至最新稳定版本(我猜这是解决您问题的解决方案)

重建项目后,单击“工具”->“Android”->“将项目与渐变文件同步”

文件-->无效更改/重新启动在我的案例中有所帮助。此外,清理和重建项目也会有所帮助。我会使缓存失效/重新启动,清理项目,重建但不起作用重新导入您的项目,这对我来说通常是可行的在mac中如何做到这一点?我是否应该将安卓studio从当前版本3.2.1升级到更高版本?是的,当前最新版本是3.3.2如果我没有弄错,我正在升级。我会让你知道它是否有效