HarmonyOS鸿蒙Next中failed to init or restore uicontent with file pages/Index. errorCode: 13
HarmonyOS鸿蒙Next中failed to init or restore uicontent with file pages/Index. errorCode: 13
DevEco Studio版本
DevEco Studio 5.0.0 Release
Build #DS-233.14475.28.36.503906
Build Version: 5.0.3.906, built on October 21, 2024
Runtime version: 17.0.12+1-b1087.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Registry:
idea.plugins.compatible.build=IC-233.14475.28
HarmonyOS SDK版本信息
HarmonyOS 5.0.0 Release SDK, based on OpenHarmony SDK Ohos_sdk_public 5.0.0.71 (API Version 12 Release)
报错信息
[appspawn_common.c:509]no need set fd info 1, 0
[sandbox_utils.cpp:280]errno is: 13, private mount to /mnt/sandbox/100/com.example.arktsdemo01/data/service/el0/public-for-all-app failed
[sandbox_utils.cpp:280]errno is: 13, private mount to /mnt/sandbox/100/com.example.arktsdemo01/data/utd failed
[sandbox_utils.cpp:267]mount /mnt/sandbox/100/com.example.arktsdemo01/mnt/storage/Users/currentUser time 11910 us
[sandbox_utils.cpp:267]mount /mnt/sandbox/100/com.example.arktsdemo01/mnt/storage/external time 10661 us
[sandbox_utils.cpp:267]mount /mnt/sandbox/100/com.example.arktsdemo01/mnt/storage/hmdfs time 10224 us
[sandbox_dec.c:188]open dec file fail.
[appspawn_silk.c:118]Load silk library failed for configItems is NULL
pid[10170] first get g_tagsProperty: 5456538433256433664
[Interface] task 10180 apply qos failed, errno = 4
3:MonitorMain:123 blockaware init fail, ret[22], key[0x0]
4:operator():38 [1995852576] set priority failed ret[1] errno[0]
[main_thread.cpp:3322]emptye config
<764>AddDisplayIdFromAms: abilityToken is nullptr or display id invalid.
[js_ability_stage.cpp:167]stage is nullptr
[app_recovery.cpp:119]not enabled
[ecmascript] Can not open xpm proc file, do not check secure memory anymore.
[Interface] task 10178 apply qos failed, errno = 4
[Interface] task 10177 apply qos failed, errno = 4
[Interface] task 10179 apply qos failed, errno = 4
[ui_ability.cpp:493]appRecovery not recovery restart
<764>AddDisplayIdFromAms: abilityToken is nullptr or display id invalid.
<522>GetDisplayInfo: screen id is invalid
[ui_ability_impl.cpp:290]hasSaveData_: false
[window_session_impl.cpp] SetWindowType<1541>: set window type permission denied!
<>: CHKPR(enhanceCfg_) is null, return value is -1
<>: CHKPV(enhanceCfg_) is null
<82>GetSingleton: can not get OHOS::Rosen::WindowInfoReporter
[ui_ability.cpp:261]appRecovery not recovery restart
[Init]: do not enabled!ret: -1
[ui_ability_impl.cpp:408]null applicationContext or lifecycleCallback
write trace_marker failed, 9
[accessibility_system_ability_client_impl.cpp(AccessibilitySystemAbilityClientImpl:55)]accessibility service is ready.
<(100000:100000:scope)] ERROR EACCES
<(100000:100000:scope)] ERROR EACCES
<1262>SetUIContentInner: failed to init or restore uicontent with file pages/Index. errorCode: 13
Failed to load the content. Cause: {"code":401}
pid[10170] first get g_tagsProperty: 5456538433256433664
现象描述
启动并进入到入口页时报错,模拟器为空白页
代码
// Index.ets
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
// 使用文本组件
Text(this.message)
.fontSize(50) //设置字体大小
.fontWeight(FontWeight.Bold) //设置字体加粗
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
// 添加按钮组件,以响应用户点击
Button(){
Text('跳转') //设置按钮名称
.fontSize(20) //设置按钮名称字体大小
.fontWeight(FontWeight.Bold) //设置按钮字体加粗
}
.type(ButtonType.Capsule) //设置按钮类型
.margin({top: 20 }) //设置按钮上外边距为20
.backgroundColor('#0D9FFB')//设置按钮背景颜色
.width('40%') //设置按钮宽度
.height('5%') //设置按钮高度
}
.width('100%')
}
.height('100%')
}
}
更多关于HarmonyOS鸿蒙Next中failed to init or restore uicontent with file pages/Index. errorCode: 13的实战教程也可以访问 https://www.itying.com/category-93-b0.html
上述代码未发现问题,可以排查下是不是EntryAbility加载页面有问题
更多关于HarmonyOS鸿蒙Next中failed to init or restore uicontent with file pages/Index. errorCode: 13的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
你好,我也出现了这个问题,请问那个加载页面怎么排查呀,
针对您遇到的鸿蒙应用加载错误,以下是详细的解决方案:
错误分析
-
errorCode 13:通常表示UI资源加载失败
-
errorCode 401:权限校验失败
解决方案步骤
- 检查页面路由配置
在src/main/resources/base/profile/main_pages.json
中确认:
{
"src": [
"pages/Index" // 确保路径大小写一致
]
}
- 验证权限配置
在module.json5
中添加必要权限:
{
"module": {
"requestPermissions": [
{
"name": "ohos.permission.INTERNET" // 网络权限
},
{
"name": "ohos.permission.READ_MEDIA" // 媒体读取权限
}
]
}
}
- 检查Index页面基础结构
pages/Index.ets
基础模板:
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Column() {
Text(this.message)
.fontSize(30)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
.padding(12)
}
}
- 资源文件校验
确保资源目录结构符合标准:
src/
main/
resources/
base/
element/
media/
profile/
ets/
pages/
Index.ets
在HarmonyOS鸿蒙Next中,出现“failed to init or restore uicontent with file pages/Index. errorCode: 13”错误,通常是由于UI内容初始化或恢复失败引起的。错误代码13可能指示以下几种情况:
-
文件路径错误:
pages/Index
文件路径可能不正确或文件缺失,导致系统无法找到并加载该文件。检查文件路径和文件名是否正确,并确保文件存在于指定位置。 -
资源文件损坏:
pages/Index
文件可能已损坏或不完整,导致系统无法正确解析。尝试重新创建或替换该文件,确保其内容完整且符合鸿蒙系统的规范。 -
权限问题:系统可能没有足够的权限访问
pages/Index
文件。检查文件权限设置,确保系统有读取和执行的权限。 -
UI组件配置错误:
pages/Index
文件中可能包含不正确的UI组件配置,导致初始化失败。检查文件中的UI组件定义,确保其符合鸿蒙系统的UI框架要求。 -
系统兼容性问题:鸿蒙Next版本可能存在某些兼容性问题,导致特定文件无法正确加载。确保开发环境和运行环境均为最新版本,并检查是否有已知的兼容性问题。
-
缓存问题:系统缓存可能导致文件加载失败。尝试清除应用缓存或重启设备,重新加载
pages/Index
文件。
根据上述情况,逐一排查并解决问题,确保pages/Index
文件能够正确加载和初始化。
在HarmonyOS鸿蒙Next中,failed to init or restore uicontent with file pages/Index. errorCode: 13
错误通常表示在初始化或恢复UI内容时发生了问题。错误代码13可能指示文件路径错误或资源文件缺失。建议检查pages/Index
文件路径是否正确,确保文件存在且内容完整。同时,确认项目配置文件中是否正确引用了该文件。若问题持续,尝试清理项目缓存并重新构建。