当前位置: 首页 > 知识库问答 >
问题:

我试图创建ListView并从字符串中获取数据,但出现了这个错误

耿运浩
2023-03-14
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"/Users/macos/Documents/SubmissionExpert1/app/src/main/res/layout/data.xml","position":{"startLine":11}}],"original":"/Users/macos/Documents/SubmissionExpert1/app/src/main/res/layout/data.xml:12: AAPT: error: resource string/name_heroes (aka com.example.submissionexpert1:string/name_heroes) not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"/Users/macos/Documents/SubmissionExpert1/app/src/main/res/layout/data.xml","position":{"startLine":20}}],"original":"/Users/macos/Documents/SubmissionExpert1/app/src/main/res/layout/data.xml:21: AAPT: error: resource string/lorem (aka com.example.submissionexpert1:string/lorem) not found.\n    ","tool":"AAPT"}

失败:生成失败,出现异常。

>

执行时发生故障com.android.build.gradle.internal.tasks.工人$ActionFacade Android资源链接失败 /Users/macos/Documents/SubmissionExpert1/app/src/main/res/layout/data.xml:12: AAPT:错误:资源字符串/name_heroes(又名com.example.submissionexpert1: string/name_heroes)未找到。

/用户/macos/Documents/SubmissionExpert1/app/src/main/res/layout/data。xml:21:AAPT:error:resource-string/lorem(又名com.example.submissionexpert1:string/lorem)未找到。

尝试:使用--stacktrac选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多html" target="_blank">日志输出。使用--scan运行以获得完整的见解。

获取更多帮助https://help.gradle.org

构建在20个可操作任务中失败:4个已执行,16个最新

共有1个答案

慕容文昌
2023-03-14

看起来您在布局中没有名为data.xml的文件,或者您需要为build.gradle.中的资源配置源集

在您的构建中遵循以下原则。gradle:

sourceSets {
    main {
        resources {
            srcDir 'app/main/res'
        }
    }
}
 类似资料: