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

Android Studio配置异常:所有项目均显示Lorem Ipsum而非预设内容

问题描述

原本正常运行的简单Android应用,添加新TextView后开始显示Lorem Ipsum而非预设内容。新建默认的“Hello Android”应用,结果依然显示Lorem Ipsum,所有项目都出现这个问题。

编译SDK版本为34,使用Kotlin语言及Gradle构建工具,MainActivity.kt中未找到任何调用Lorem Ipsum的代码,代码如下:

package com.example.test

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.test.ui.theme.TestTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TestTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    Greeting("Android")
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(
        text = "Hello $name!",
        modifier = modifier
    )
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    TestTheme {
        Greeting("Android")
    }
}
解决方法

这种情况基本是Android Studio的工具或缓存问题导致的,试试以下步骤:

  • 关闭Compose布局检查器:打开AS设置(File > Settings),找到Experimental选项,取消勾选Enable Compose Layout Inspector,重启AS。这个工具偶尔会用Lorem Ipsum替换文本做布局预览,可能意外影响到实际运行。
  • 清理重建项目:点击菜单栏Build > Clean Project,完成后再点Build > Rebuild Project;或者直接删除项目根目录的.gradle和build文件夹,然后同步Gradle(右上角Sync按钮)。
  • 清除应用缓存:在模拟器/真机上,进入应用设置,找到你的APP,清除数据和缓存后重新安装。
  • 更新工具和依赖:检查Android Studio是否为最新版本(Help > Check for Updates),同时确保Compose相关依赖(比如compose-bom、material3)的版本适配SDK 34。
  • 临时禁用预览代码:注释掉@Preview注解的函数,再运行项目看看是否恢复正常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 13:12:56