错误“无法解析的参考:activity_splash”

问题描述 投票:0回答:2

我刚刚在Android Studio中创建了新的空活动。

飞溅活动类:

    package com.example.layoutpractice

    import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle

    class Splash : AppCompatActivity() {

        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_splash)
        }
    }

飞溅活动XML文件:

    //activity_splash.xml
    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
        android:layout_height="match_parent">

    </androidx.constraintlayout.widget.ConstraintLayout>

如您所见,我没有对代码进行任何更改。但是我在Android Studio中仍然出现错误。Splash.kt

我什至按照Android编辑器的建议删除并重新创建了.xml文件,但它没有改变。

android android-layout kotlin
2个回答
0
投票

检查是否有任何进口,如

import android.R 

如果有,请删除并重新导入


0
投票

使缓存无效并重新启动Android Studio。 File-> Invalidate Caches / Restart...

© www.soinside.com 2019 - 2024. All rights reserved.