Android The layout "activity_main" in layout has no declaration in the base layout folder
报错:
The layout "activity_main" in layout has no declaration in the base layout folder; this can lead to crashes when the resource is queried in a configuration that does not match this qualifier.
详情:
If a resource is only defined in folders with qualifiers like -land or -en, and there is no default declaration in the base folder (layout or values etc), then the app will crash if that resource is accessed on a device where the device is in a configuration missing the given qualifier. As a special case, drawables do not have to be specified in the base folder; if there is a match in a density folder (such as drawable-mdpi) that image will be used and scaled. Note however that if you only specify a drawable in a folder like drawable-en-hdpi, the app will crash in non-English locales. There may be scenarios where you have a resource, such as a -fr drawable, which is only referenced from some other resource with the same qualifiers (such as a -fr style), which itself has safe fallbacks. However, this still makes it possible for somebody to accidentally reference the drawable and crash, so it is safer to create a default dummy fallback in the base folder. Alternatively, you can suppress the issue by adding tools:ignore="MissingDefaultResource" on the element. (This scenario frequently happens with string translations, where you might delete code and the corresponding resources, but forget to delete a translation. There is a dedicated issue id for that scenario, with the id ExtraTranslation.) Issue id: MissingDefaultResource
翻译:
如果资源仅在具有-land或-en等限定符的文件夹中定义,并且基本文件夹(布局或值等)中没有默认声明,则如果在设备所在的设备上访问该资源,则应用程序将崩溃在配置中缺少给定的限定符。
作为特殊情况,不必在基础文件夹中指定drawable;如果密度文件夹(例如drawable-mdpi)中存在匹配,则将使用和缩放图像。但请注意,如果您只在drawable-en-hdpi等文件夹中指定drawable,则应用程序将在非英语语言环境中崩溃。
在某些情况下,您可能会拥有一个资源,例如-fr drawable,它仅从具有相同限定符的某些其他资源(例如-fr样式)引用,该资源本身具有安全回退。但是,这仍然可以让某人意外地引用drawable和crash,因此在基础文件夹中创建默认的虚拟回退更安全。或者,您可以通过在元素上添加工具:ignore =“MissingDefaultResource”来解决此问题。
(这种情况经常发生在字符串翻译中,您可能会删除代码和相应的资源,但忘记删除翻译。该方案有一个专用的问题ID,ID为ExtraTranslation。)
解决方法:
添加
tools:ignore="MissingDefaultResource"
不知道会不会有后遗症,后续若有解决方法来此编辑~望有大佬指示。
Android The layout "activity_main" in layout has no declaration in the base layout folder的更多相关文章
- Android studio新建文件出现setContentView(R.layout.activity_main);中的R标红错误解决方法
今天打开Android studio突然出现了setContentView(R.layout.activity_main);中的R标红错误,这已经不是第一次出现这个错误了,真心的觉得Android s ...
- setContentView(R.layout.activity_main)无法正常引用
今天在写Android代码的过程中,编译器一直报错,错误出在这一行代码: setContentView(R.layout.activity_main) 提示信息是: activity_main can ...
- android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)
1.layout切换动画 代码: 本示例是fragment切换.在它的oncreateView中 public class LayoutAnimationFrgmt extends Fragment ...
- Android View体系(八)从源码解析View的layout和draw流程
前言 上一篇文章我们讲了View的measure的流程,接下来我们讲下View的layout和draw流程,如果你理解了View的measure的流程,那这篇文章自然就不在话下了. 1.View的la ...
- intellij idea android错误: Missing styles. Is the correct theme chosen for this layout?
Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layou ...
- Android Studio 打开activity_main.xml不能正常显示
操作系统:Windows 10 x64 IDE:Android Studio 3.2.1 解决方法:http://www.jcodecraeer.com/a/anzhuokaifa/Android_S ...
- Android错误之--activity_main cannot be resolved or is not a field
一般在copy别人的项目中会easy出现本错误,截图例如以下:
- 导入别人的Android项目,提示 /Libs/gen already exists but is not a source folder. Convert to a source folder or rename it
解决方法: 遇到这个问题的解决方法: 1. 右键点击工程,选择 "Properties" 2. 选择左边的 "Java Build Path" 3. 打开 &q ...
- Android入门(五)UI-单位与尺寸、ListView
原文链接:http://www.orlion.ga/453/ 一.单位与尺寸 布局文件中一共有以下单位供选择:px,pt,dp,sp px:是像素,屏幕中可见的最小元素单位. pt:是磅,1磅等于1/ ...
随机推荐
- 2020JAVA最新应对各种OOM代码样例及解决办法
引言 作者:黄青石 链接:https://www.cnblogs.com/huangqingshi/p/13336648.html?utm_source=tuicool&utm_medium= ...
- Day09_商品管理
学于黑马和传智播客联合做的教学项目 感谢 黑马官网 传智播客官网 微信搜索"艺术行者",关注并回复关键词"乐优商城"获取视频和教程资料! b站在线视频 0.学习 ...
- Day02_IP地址详解&进制转换&DOS基本命令与批处理
学于千峰教育开源课程 感谢 千峰教育官网 b站在线视频 IP地址详解 一.简单局域网的构成 局域网:一般称为内网 简单局域网的构成:交换机.网线.PC(其他IT终端) 交换机:用来组建内网的局域网的设 ...
- 图解HTTP 6/11
第三章 HTTP报文内的HTTP信息 1.用于http协议交互的信息被称为HTTP报文.请求端(客户端)的HTTP报文叫做请求报文,响应端(服务器端 )的叫做响应报文. 2.请求报文的结构 请求行:包 ...
- 下载数据到csv中(乱码),使用numpy , pandas读取失败 解决方案
读取数据,下载数据到 csv 文件中 allUniv 列表类型[[...],[...]] 字符集编码使用 utf-8-sig with open('文件名.csv','w',newline='',en ...
- PHP fnmatch() 函数
定义和用法 fnmatch() 函数根据指定的模式来匹配文件名或字符串. 语法 fnmatch(pattern,string,flags) 参数 描述 pattern 必需.规定要检索的模式. str ...
- ElasticSearch 基础入门 and 操作索引 and 操作文档
基本概念 索引: 类似于MySQL的表.索引的结构为全文搜索作准备,不存储原始的数据. 索引可以做分布式.每一个索引有一个或者多个分片 shard.每一个分片可以有多个副本 replica. 文档: ...
- Lambda表达式运行原理
目录 一.创建测试样例 二.利用Java命令编译分析 三.文末 JDK8引入了Lambda表达式以后,对我们写代码提供了很大的便利,那么Lambda表达式是如何运用简单表示来达到运行效果的呢?今天,我 ...
- 使用hibernate validate做参数校验
1.为什么使用hibernate validate 在开发http接口的时候,参数校验是必须有的一个环节,当参数校验较少的时候,一般是直接按照校验条件做校验,校验不通过,返回错误信息.比如以下校验 ...
- POJ 2443 Set Operation 题解
本文同时发布于 博客园 洛谷博客 题目链接 题目分析 给你n个集合,每个集合里面都有可能会重复的数字 q个询问,每次询问两个数是否会在同一集合内 $n<=1000$ $q<=200000$ ...