You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio新建空Activity后出现unresolved reference: activity_splash错误

Hey there! Let's troubleshoot why your brand-new empty Splash Activity is throwing errors even when you haven't touched the code, and rebuilding the XML didn't fix it. Here are the most common culprits and fixes to try:

Common Issues & Solutions

1. Wrong AndroidManifest.xml Configuration

Even an empty Activity needs proper registration in your manifest, especially if it's set as the launcher activity. Double-check your AndroidManifest.xml:

  • Make sure the Splash Activity is declared correctly. If it's your app's entry point, it should look like this:
<activity
    android:name=".Splash"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
  • If it's not the launcher activity, remove the <intent-filter> block and keep only the basic <activity> tag.

2. Android Studio Cache Glitches

Sometimes the IDE's cached data gets corrupted, and rebuilding the XML alone won't clear it. Try this:

  • Go to File → Invalidate Caches... → Select Invalidate and Restart. This will clear all cached resources and restart Android Studio, which often fixes weird layout or compilation errors.
  • Also, ensure your XML filename follows Android's rules: no uppercase letters, spaces, or special characters (only underscores are allowed). activity_splash.xml is correct, but if you had a bad name before, make sure the new one is compliant.

3. Missing or Broken ConstraintLayout Dependency

Your layout uses ConstraintLayout, so if that dependency isn't properly added to your project, it'll throw errors. Check your module-level build.gradle file:

  • Verify that the ConstraintLayout dependency is present (use the latest stable version if possible):
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
  • Click Sync Now to sync the project with the updated dependencies.

4. Tiny XML Syntax Mistakes

Even an empty layout can have hidden syntax issues. Double-check your activity_splash.xml:

  • Confirm the opening XML declaration and namespace are correct (your code looks right, but it's worth verifying again):
<?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>
  • Make sure there are no extra spaces, unclosed tags, or typos in attribute names.

If none of these fix the problem, share the exact error message from Android Studio (whether it's a compile error, layout preview error, or runtime crash) — that'll help narrow down the issue even more!

内容的提问来源于stack exchange,提问作者chriskwon7007

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 19:32:38