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/ ...
随机推荐
- 题解 洛谷 P4632 【[APIO2018] New Home 新家】
首先考虑可以用二分答案来解决询问,可以二分一个长度\(len\),若在区间\([x-len,x+len]\)内包含了所有\(k\)种的商店,那么这个\(len\)就是合法的,可以通过二分来求其最小值. ...
- 为什么我推荐Nginx作为后端服务器代理
1. 前言 我们真实的服务器不应该直接暴露到公网上去,否则更加容易泄露服务器的信息,也更加容易受到攻击.一个比较"平民化"的方案是使用Nginx反向代理它.今天就来聊一聊使用Ngi ...
- DJANGO-天天生鲜项目从0到1-009-搜索功能实现(django-haystack+whoosh+jieba)
本项目基于B站UP主‘神奇的老黄’的教学视频‘天天生鲜Django项目’,视频讲的非常好,推荐新手观看学习 https://www.bilibili.com/video/BV1vt41147K8?p= ...
- 04爬取拉勾网Python岗位分析报告
# 导入需要的包import requestsimport time,randomfrom openpyxl import Workbookimport pymysql.cursors#@ 连接数据库 ...
- Window版本的Python安装库大全
1. 位置 python的pip安装包网站 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 下载方法 wget https://download.lfd.uci ...
- Numpy修改数组中的元素值
import numpy as np x = np.arange(8) # [0 1 2 3 4 5 6 7] # 在数组尾部追加一个元素 np.append(x,10) # array([ 0, 1 ...
- PHP uksort() 函数
------------恢复内容开始------------ 实例 使用用户自定义的比较函数对数组 $arr 中的元素按键名进行排序: <?phpfunction my_sort($a,$b){ ...
- PHP empty() 函数
empty() 函数用于检查一个变量是否为空.高佣联盟 www.cgewang.com empty() 判断一个变量是否被认为是空的.当一个变量并不存在,或者它的值等同于 FALSE,那么它会被认为不 ...
- layer.js : n.on is not a function
当时使用的jQuery为1.4.x的版本.换成高版本就好了. 参考 https://blog.csdn.net/marswill/article/details/69316003
- Golang SQL连接池梳理
目录 一.如何理解数据库连接 二.连接池的工作原理 三.database/sql包结构 四.三个重要的结构体 4.1.DB 4.2.driverConn 4.3.Conn 五.流程梳理 5.1.先获取 ...